I'm trying to update values on a feature layer that is hosted on ArcGIS online. When I run the below code, nothing is updated but I do notice that the date modified changes to reflect the last time I run the code. Any ideas? I feel like it might have to do with settings/permissions on the hosted layer? I made sure editing was allowed and tried making it publicly shared as well. Any help is appreciated. Thanks
const layer = new FeatureLayer({
});
const query = new Query();
query.where = "ISO = 'VA'";
query.outSpatialReference = {
wkid: 102100
};
query.returnGeometry = true;
query.outFields = ["haveData", "ISO",];
layer.queryFeatures(query).then(function (results) {
console.log('before update');
console.log(results.features[0].attributes.haveData);
// update the appropriate value
results.features[0].attributes.haveData = 22.0;
console.log('after update'); // this checks out, displays what I want
console.log(results.features[0].attributes.haveData);
console.log(results.features[0]) // this also displays the new value that I want
let edits = {
updateFeatures: [results.features[0]]
};
layer.applyEdits(edits).then(function (editsResult) {
})
.catch(function (error) {
console.error("[ applyEdits ] FAILURE: ", error.code, error.name,
error.message);
});
});