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[i];  
            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);  
        }, function (e) {  
            console.log("Error switching phases!", e);  

OK, I found the root cause. We are using ESRI's PHP proxy, and it was a bug in that. Upgrading to the latest 1.1 beta solved the issue. Here is the link to their repo: https://github.com/Esri/resource-proxy

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.