Select to view content in your preferred language

EditorWidget applyEdits not automatically querying newly created feature

187
2
08-01-2025 07:23 AM
SebastianKrings
Frequent Contributor

TL;DR

My problem is, that after creating a feature in the EditorWidget the Feature is not shown in the map. It is not queried. In another identical ap (clone) but different deployment it works just fine.

You can find a table about differences below.

What am I missing and how do I fix it or work around?

Long Version

In our app (called B) we are using a simple EditorWidget:

 

const mapView = await this._mapViewPromise;
this._activeEditor = new Editor({
    view: mapView,
    container: this.canvasId
});

 

After drawing and typing data into the form and clicking so save it, the Feature is created.
But: Its not visible until I refresh the whole page.
Checking the network tab shows, that there is no query sent to retrieve the created feature.

SebastianKrings_0-1754055004502.png

 

After pressing F5, all Features appear:

SebastianKrings_1-1754055251838.png

payload of applyEdits with adds-object nested in edits-object:

SebastianKrings_6-1754056318979.png

 



Since we copied the app code from another app (called A) and modified some other things I tried the same there and:
The other app immediately is showing the new feature and I can see a query in the network tab.

SebastianKrings_4-1754055730138.png

payload of applyEdits with adds-object:

SebastianKrings_7-1754056446878.png

 

 

So both apps, being clones but used in different deployments do different things.

What are the differences I recognize so far?

AB (clon of A)
automatically queries the new Featureno query after applyEdits
thus shows new feature on map directlyF5 needed to show new Features
uses a hosted FeatureService from its own ArcGIS Portaluses a FeaturesService from its own ArcGIS Portal but connected to Enterprise GeoDB (so not shown as "hosted" in the portal)
directy uses 'adds'-object in payloadnests the 'adds'-object inside an 'edits'-object also containing nested 'edits' and 'deletes' with null
RequestURL:
https://myA.local/server1/rest/services/Hosted/MyAService/FeatureServer/2/applyEdits
RequestURL:
https://shgdi-myB.local/server/rest/services/myB/MyBService/FeatureServer/applyEdits
Layers are added like map.add(new WFSLayer(props)Layers added automatically via WebMap:
const map = new WebMap(...)
new MapView(..., map, ....)
  
  


Regarding the different request URL I found these two different docs about applyEdits:
https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service/
https://developers.arcgis.com/rest/services-reference/enterprise/apply-edits-feature-service-layer/

It seems that when applyEdits on FeaturesServer does not run the query afterwards while the applyEdits on FeatureServer/Layer does.

Since I am out of ideas I am wondering whether:
- this is a bug in FeatureServer-applyEdits
- this is intended for some reason
- it is due to some different configuration (like a flag to decide to not to run the query afterwards).

Any ideas and info are welcome.

 

0 Kudos
2 Replies
SebastianKrings
Frequent Contributor

As workaround I tried to simply query the new feature during interceptor after part:

const creationSuccessfulInterceptor: __esri.RequestInterceptor = {
    urls: layerUrls,
    after: async (response) => {
        // iterate over response.data + response.data[].addResults
        // take the layerId from data and take the objectId from addResults
        const objectIdByLayerIdMap = this.retrieveObjectIdsAndLayerId(response);
        
        // get the layer object
        const layer = this.retrieveLayerFromView(objectIdByLayerIdMap);
        
        // query new features from that layer
        layer.queryFeatures({objectIds: objectIds});
    }
}

 
But only querying it did not bring it visible. Am I missing something?

 

What works better is to just refresh the full layer. But instead of a single smooth feature query, many geometry queries are performed returning all current visible features of that layer.
At least the new Feature is shown now!

// call refresh instead querying a single feature
layer.refresh();

SebastianKrings_0-1754076570923.png

I still hope for better ideas to clarify whether there is a bug in applyEdits or how to get it working correctly without the need of an interceptor.

 

0 Kudos
SebastianKrings
Frequent Contributor

We just found out, that this behaviour also appears within ExperienceBuilderApps. Using the editor widget does not show the Feature unless one forces a query by either reloading or heavy zooming.

Guess thats a BUG though.

0 Kudos