Brian.Cheung_WspCanada

Editing the attribute of all features (JS API 4.8)

Discussion created by Brian.Cheung_WspCanada on Sep 14, 2018

I am trying to update the value of an attribute for each feature in a layer by setting its value to 1 when the map loads. Here is the code I've tried:

featureLayer.queryFeatures().then(function(results){
         
   var updatedFeatures = [];
         
   if (results.features.length > 0){
      results.features.forEach(function(element){
         element.attributes.att3temp = 1;
         updatedFeatures.push(element);
      });
           
      featureLayer.applyEdits({
         updateFeatures: updatedFeatures
      });

    }
});

 

When I try running the code, nothing seems to happen. Am I missing something here?

 

Thanks in advance for any assistance/pointers!

Outcomes