AnsweredAssumed Answered

promise all issue with applyEdits

Question asked by random12345 on Apr 11, 2014
Latest reply on Apr 11, 2014 by Jian
I am trying to properly handle the errors generated by this code and am missing something fundamental.  I have 4 records to add.  I queue them up async and wait for 4 promises to fulfill before continuing.  But one of them fails.  How do I determine which of the 4 failed?

Thanks in advance.

var namesObj =  [    // sample namesObj it is loaded from a file.
                   { siteID:1,
      study_no:1 },
     { siteID:2,
      study_no:2 },
     { siteID:3,
      study_no:3 },
     { siteID:4,
      study_no:4 },
var counter = 0;
var deferredArray = [];
for (var i=0; i<namesObj.length; i++) {
myNewAttributeArray = {
   "SiteID" : namesObj[i].SiteID,
   "Study_NO" : namesObj[i].study_no
var myG = new esri.Graphic(null, null, myNewAttributeArray, null);
// featureLayers[14] is created much earlier in the code.
deferredArray[counter] = gl.featureLayers[14].applyEdits([myG],null,null,function(result) {
  // add success
}, function(error) {
  // add fail, "error" message contains nothing about what failed
  // How can I pass something into this function so that I know which failed so I can try
  //  again to add the record, or output a useful message to the user?
all(deferredArray).then( function() {
// this fires if all DB adds succeed
}, function() {
// this never fires

This is the "error" message.
error.message is "Unable to complete operation."
error.details[0] is "Unable to perform applyEdits operation."