AnsweredAssumed Answered

Edit features (FeatureLayers ApplyEdits) - 4.3

Question asked by andreribeiro on Jun 2, 2017
Latest reply on Apr 12, 2018 by 96213@charlottenc.gov_charlotte

I tried to use this sample (Edit Features | ArcGIS API for JavaScript 4.3) but with some changes. Instead of use a portalItem I want to use a featureLayer. I already changed to my feature layer url and add the class to the require and to the function, they worked good.
My problem is when I click on a feature, instead of appear in the input boxes the attributes that are in the feature layer, appear the word "undefined" like in the picture below:

 

 

I can select and add new points successfully, that's why I think that isn't normal I can't fetch the attributes to my input boxes.
This is the code when I select a feature:

 

function selectFeature(objectId) {
           //quadrado
          // symbol for the selected feature on the view
          var selectionSymbol = SimpleMarkerSymbol({
            color: [0, 0, 0, 0],
            style: "square",
            size: '35px',
            outline: {
              color: [255, 96, 0, 0.66],
              width: 2
            }
          });

          var query = featureLayer.createQuery();
          query.where = featureLayer.objectIdField + " = " + objectId;

          featureLayer.queryFeatures(query).then(function(results) {
            if (results.features.length > 0) {
              editFeature = results.features[0];
              editFeature.symbol = selectionSymbol;
              view.graphics.add(editFeature);
            }
          });
}

 

And this is the code when I fetch the attribute results to the input boxes:

 

view.on("click", function(evt) {          
  unselectFeature();         
  view.hitTest(evt.screenPoint).then(function(response) {           
    if (response.results.length > 0 && response.results[0].graphic) {
      var feature = response.results[0].graphic;             
      selectFeature(feature.attributes[featureLayer.objectIdField]);                          
      inputDescription.value = feature.attributes["equipament"];
      inputUserInfo.value = feature.attributes["num_i_s"];                             
      form1.value = feature.attributes["lado"];                                 
      form2.value = feature.attributes["sustent"];                             
      form3.value = feature.attributes["braco"];
      form4.value = feature.attributes["botoneira"];                             
      form5.value = feature.attributes["av_acustic"];                             
      attributeEditing.style.display = "block";             
      updateInstructionDiv.style.display = "none";           
    }         
  });       
});


I already search a lot about this topic but I don't find anything that helps me. Anyone?

Thank you,
André Ribeiro

Outcomes