const toDelete = new esriJS.EsriGraphic();
toDelete.setAttributes({})
toDelete.attributes.objectid = objectid;
const featureLayer = new esriJS.FeatureLayer(featureLayerUrl);
featureLayer.applyEdits(null, null, [toDelete],
(adds, updates, deletes) => {
resolve(deletes);
},
err => {
console.log(err);
debugger
reject(err);
});
Solved! Go to Solution.
In order for the applyEdits operation to successfully process the deletes, the objectIdField must be set. Although I suppose you could manually set it, this ordinarily doesn't take place until the layer has loaded. Therefore, I would recommend something like the following change:
const featureLayer = new esriJS.FeatureLayer(featureLayerUrl);
featureLayer.on("load", function() {
featureLayer.applyEdits(null, null, [toDelete], (adds, updates, deletes) => {
resolve(deletes);
}, err => {
console.log(err);
debugger
reject(err);
});
});
Waiting for the layer to load before calling applyEdits may also solve the problem you were having in the other thread.
In order for the applyEdits operation to successfully process the deletes, the objectIdField must be set. Although I suppose you could manually set it, this ordinarily doesn't take place until the layer has loaded. Therefore, I would recommend something like the following change:
const featureLayer = new esriJS.FeatureLayer(featureLayerUrl);
featureLayer.on("load", function() {
featureLayer.applyEdits(null, null, [toDelete], (adds, updates, deletes) => {
resolve(deletes);
}, err => {
console.log(err);
debugger
reject(err);
});
});
Waiting for the layer to load before calling applyEdits may also solve the problem you were having in the other thread.