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")}});});
Hi,
If you're making updates, each feature has to have a valid ObjectID. In the code above, you have that value commented out. What happens if you include it?
Jill
Hello, even when I put in the ObjectID nothing is updated..
Hi,
What is the response that you're getting?
Can you perform the applyEdits operation in the REST Service Directory to validate your parameters?
Hi there,
Please take a look at the FeatureLayer.applyEdits doc. To update features, you must pass in array or collection of features! So you have to update your code to query the features your want to update, then update the attributes of the features and pass in those features to the FeatureLayer's updateFeatures param.
So you'd have to something like the following:
// editFeature is a feature you got from your feature layer
editFeature.attributes[announcement] = newAnnouncement;
// Setup the applyEdits parameter with updates.
const edits = {
updateFeatures: [editFeature]
};
featureLayer.applyEdits(edits).then((editsResult) => {
console.log(editResult);
})
.catch((error)=>{
console.log(error);
});
Please take a look at the following two samples as they both use FeatureLayer.applyEdits:
https://developers.arcgis.com/javascript/latest/sample-code/sandbox/?sample=editing-applyedits
Sorry, I am currently using arcgis api 3.25 I forget to mention this earlier. But thank you for your solution!