AnsweredAssumed Answered

Editing Feature Layers in Esri JS API 4

Question asked by 96213@charlottenc.gov_charlotte on Aug 13, 2018
Latest reply on Aug 13, 2018 by 96213@charlottenc.gov_charlotte

Hey Team!

 

I'm struggling with what was an easy workflow in Esri's 3.x JS API -- editing features. 

 

I've started with the Esri provided sample (ArcGIS API for JavaScript Sandbox) and run into a few hiccups that seemingly stem from the feature layer's source (i.e. adding an item from Portal rather than adding a feature layer directly (difference shown below):

 

 // add an editable featurelayer from portal
        Layer.fromPortalItem({
            portalItem: { // autocasts as new PortalItem()
              id: "511b97fc0d364367b127f8ba5c89ad13"
            }
          }).then(addLayer)
          .catch(handleLayerLoadError);

        setupEditing();
        setupView();

        function addLayer(layer) {
          featureLayer = layer;
          map.add(layer);
        }

vs. 

        var lineSample = new FeatureLayer({
          url: "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/FeatureServer/3"
        });

        map.add(lineSample);

 

 

It appears that the esri sample (first) uses the layer as a callback-promise subsequently and the layer has some 'implicit' properties that get passed, specifically the fields. When using a Feature Layer the only fields I'm seeing when I console.log the hitEvent results are the objectID and the created_user, while the esri sample has all of the layer's attributes.

 

If someone could point me in the right direction for how to properly define the Feature Layer's schema so that it can be passed into the editor-form, I'd be super appreciative! 

 

Robert Scheitlin, GISP

Outcomes