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:
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(); }); }); }
أكثر...
The interesting observations:
- Failure only happens on certain features and all cases belong to a particular layer (other features in that layer are just fine).
- Changing from 3.12 to 3.14 the features that cause the error are changed but did not go away.
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(); }); }); }
أكثر...