Select to view content in your preferred language

Update FeatureLayer using applyEdits() sample error

3839
15
Jump to solution
05-17-2022 07:08 AM
luckachi
Frequent Contributor

Working with 4.23 - I am currently using a copy of the "Update FeatureLayer using applyEdits()" sample but I am running into an issue where every time I click the "Update" button after creating a point I receive an error message (below) in the console.log

 

Uncaught (in promise) 
l {name: 'feature-layer:unsupported-operation', details: undefined, message: 'Layer does not support updating features.'}
details: undefined
message: "Layer does not support updating features."
name: "feature-layer:unsupported-operation"
[[Prototype]]: c

 

 

The graphic point is created just fine but none of the information I type into the feature form is saved. Also, if I click on an existing point and try to update those attributes nothing works. The only attributes that are saved are the ones that I have set in the graphics layer when the point is initially created.

 

              // Create a new feature using one of the selected template items.
              editFeature = new Graphic({
                geometry: point,
                attributes: {
                  KINGDOM: attributes.KINGDOM,
                  ADD_DATE: Date.now(),
                  LATITUDE: event.mapPoint.latitude,
                  LONGITUDE: event.mapPoint.longitude,
                  LATDIR: "NORTH",
                  LONDIR: "WEST"
                }
              });

 

 

My hosted feature layer has Add, Updated and Delete all selected.

I have not made any changes to the sample code so I am not quite how to get this to work the way I need it to.

 

0 Kudos
15 Replies
luckachi
Frequent Contributor

I am not sure this would really work in this situation. The fields that I am trying to populate with the applyedits and with the query are not shown to the user nor will they be editable by the user. 

0 Kudos
luckachi
Frequent Contributor

Has anyone else encountered this issue?

I am using the code exactly as is from: https://developers.arcgis.com/javascript/latest/sample-code/editing-applyedits/ 

Below is my JSON from the hosted feature layer that contains all 4 editable layers. 

"capabilities" : "Create,Delete,Query,Update,Editing,Sync", 

"syncCapabilities" : {
    "supportsAsync" : true, 
    "supportsRegisteringExistingData" : true, 
    "supportsSyncDirectionControl" : true, 
    "supportsPerLayerSync" : true, 
    "supportsPerReplicaSync" : true, 
    "supportsSyncModelNone" : true, 
    "supportsRollbackOnFailure" : true, 
    "supportsAttachmentsSyncDirection" : true, 
    "supportsBiDirectionalSyncForServer" : true, 
    "supportedSyncDataOptions" : 4
  }, 
  "supportsApplyEditsWithGlobalIds" : true, 
  "supportsReturnDeleteResults" : true, 
  "supportsLayerOverrides" : true, 
  "supportsTilesAndBasicQueriesMode" : true, 
  "supportsQueryContingentValues" : true, 
  "supportedContingentValuesFormats" : "JSON, PBF", 
  "supportsContingentValuesJson" : 2, 
  "advancedEditingCapabilities" : {
    "supportsSplit" : false, 
    "supportsReturnServiceEditsInSourceSR" : false, 
    "supportsAsyncApplyEdits" : true, 
    "supportsReturnEditResults" : true

The point is created, I am able to see the fields and edit them but as soon as I click the "Update Incident" button in this example I receive an error in the console.log and nothing happens on screen. The point shows up in the layer but only the attributes I pass with the graphic is included, none of the attributes that the user can modify get saved.

0 Kudos
JillianStanford
Frequent Contributor

Hi,

When you click the "Update Incidents" button, what is the response from the applyEdits request?

Here is an example of a failed request. In this case the error description is pretty helpful. Although, it sounds like applyEdits is succeeding, if the point is being added to the layer.

JillianStanford_0-1653407495506.png

Can you also check the request parameters to confirm that all of the user submitted attributes are making it into the payload?

0 Kudos
luckachi
Frequent Contributor

I get no response when I click on the "Update Incidents" button. All I get is an error in the console log

luckachi_0-1653572982022.png

Yes, it seems like the add is working just fine but the update isn't. In reality, it shouldn't be submitting the point until all the information in the form is filled out. So the only information being saved with the record is the attributes here: 

 

// Create a new feature using one of the selected
              // template items.
              editFeature = new Graphic({
                geometry: point,
                attributes: {
                  KINGDOM: attributes.KINGDOM,
                  LATITUDE: event.mapPoint.latitude,
                  LONGITUDE: event.mapPoint.longitude
                }
              });

 

I also get a similar error message in the console.log if I try to delete a record even though Add, Update and Delete options are enabled in the layer settings.

 

0 Kudos
luckachi
Frequent Contributor

@JillianStanford - I was finally able to get the a test update to work via the REST API. So updates should work but I am unsure what in my code is preventing the updates. Do I need to add an API key to this?

luckachi_1-1653660913029.png

luckachi_2-1653660949809.png

 

 

0 Kudos
luckachi
Frequent Contributor

I ended up opening an ESRI ticket for this issue. As it turns out, all the settings were correct and somehow the hosted feature service must have gotten corrupted. After republishing, everything works as it should.