AnsweredAssumed Answered

Query after applyEdits() doesn't contain all new features

Question asked by michaellodes on Jun 10, 2018
Latest reply on Jul 23, 2018 by michaellodes

Hello all,

 

directly after creating and updating my hosted Featurelayer with applyEdits(), I would like to get the whole updated Featurelayer by a Query.

 

My code below does this task chain almost correctly, but sometimes it doesn't get all changes. I guess the db update by applyEdits() was not ready yet before quering it. Why? I use then() between the functions, so I thougt one function is executed when the function before has done everything correctly?

 

lyr.applyEdits({
     addFeatures: createFeatArr
    }).then(
        lyr.applyEdits({
         updateFeatures: updateFeatArr
        })).then(getFeatureIds(lyr));

 

getFeatureIds(lyr):

 

function getFeatureIds(lyr){
   
    var query = new Query();
    query.where = "1=1";
    query.outFields = ["MYSQLID", "FID"];


    var featuresArray = new Array();


    var arr = new Array();


    lyr.queryFeatures(query).then(function(results){

        results.features.forEach(function(item){

            featuresArray.push(item.attributes);



        });

        for (var prop in featuresArray) {
           
                arr[featuresArray[prop].FID] =  featuresArray[prop].MYSQLID.toString();
               
        }

        console.log("arr: " + arr);






    });

}

 

 

Someone can help me?

 

Kind Regards

Michael

Outcomes