I have this code here that when it runs it says that it is successfully updates all of the features. I am adding an attribute called 'active' and it is a string value. But when I check the attributes in either my organizations portal or in arc pro, none of the changes appear. The Feature layer even shows that it has been updated in my content explorer. Any help with this would be very appreciated, thanks!
al.forEach((layer: __esri.FeatureLayer) => {
layer.queryFeatures({ where: '1=1', outFields: ['*'], returnGeometry: false }).then((result) => {
console.log('Result', result.features)
const feats = result.features
feats.forEach((feature: __esri.Graphic) => {
feature.attributes.active = 'active'
})
updateFeaturesActiveStatus(layer, feats)
})
})
const updateFeaturesActiveStatus = async (layer: __esri.FeatureLayer, features: __esri.Graphic[]) => {
console.log("Feature updating", features);
try {
const editablLayer: __esri.FeatureLayer = getEditableFeatureLayer(layer)
const res = await layer.applyEdits({ updateFeatures: features })
console.log('Feature', features);
if (res.updateFeatureResults.length > 0 && res.updateFeatureResults[0].error) {
console.error("Update failed:", res.updateFeatureResults[0].error);
} else {
console.log("Feature updated successfully!", res.updateFeatureResults);
}
} catch (error) {
console.error('Error updating feature active status:', error)
}
}
So I don't know that I've tried updating a feature in a fashion like this, I've done add features, but some things you may check:
console.log(layer.fields.map(f => f.name));