I am using a feature layer in JSAPI, where I edit a feature by the standard selection, change attributes, applyEdits process. It seems that there is a bug in JSAPI both 3.12 and 3.14 which makes the apply edits fail on certain features. The callback just errors out without any clue.
The interesting observations:
1. Failure only happens on certain features and all cases belong to a particular layer (other features in that layer are just fine).
2. Changing from 3.12 to 3.14 the features that cause the error are changed but did not go away.
Here is a quick snippet of the code:
sq = buildSelectionQuery(); if (sq) { all(assetsFeatureLayers.map(function (l) { return l.selectFeatures(sq, esri.layers.FeatureLayer.SELECTION_NEW).promise;}) ).then(function (fls) { console.log('sel res', fls); all(fls.map(function (r, i) { var fs = r[0]; // the first is an array of selected features var l = assetsFeatureLayers; console.log(fs); if (fs.length > 0) { console.log("Switching phases to: ", tph); fs.forEach(function (f) { f.attributes['phasecode'] = tph; }); console.log("Saving switched phases for layer: ", l.name); return l.applyEdits(null, fs, null); //.promise; } else { return null; } })).then(function (l) { console.log("Phase switching finished successfully!", l); clearAllSelections(); }, function (e) { console.log("Error switching phases!", e); clearAllSelections(); }); }); }
FeatureLayer.applyEdits() always erroring on update when it actually worked see Ben Fousek 's
- this.applyEdits(null, [feature], null, function (a, u, d) {
- console.log(u[0]);
- }, function (error) {
- console.log(error);
- });
I actually found the root cause and it was the PHP proxy, updating it to the latest beta solved the issue.
Ah cool.