'Unable to applyEdits ArcGIS FeatureLayer
Good Evening,
I am trying to update my featureLayer using the applyEdits properties. I am facing some issues as I cannot change the value of the specific layer. I am not sure what is wrong here do assist me on this, cheers! (This project is running on ArcGIS API 3.25)
let testButton = document.getElementById('testButton')
if (testButton){
testButton.addEventListener("click",function(){
var announcementInput = document.getElementById('announcementInput').value;
console.log(announcementInput)
featureLayer.applyEdits(
null,
[{
"attributes":{
"objectid":objectid,
"announcement": announcementInput, // I want to update this value
}
}],
null,
null,
null
})
}
else{
console.log("Not working")
}
});
});
Solution 1:[1]
I think the problem is that you need to pass Graphic elements, you are just passing an object. It should be something like this,
// first get the feature you want to edit
const query = new Query();
query.objectIds = [objectid];
query.outFields = [ "*" ];
featureLayer.queryFeatures(query, function(featureSet) {
if (featureSet.features.length === 0) {
return;
}
// now update the desire attribute
const feature = featureSet.features[0];
feature.attributes.announcement = announcementInput;
featureLayer.applyEdits(
null,
[feature],
null,
null,
null
})
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | cabesuon |
