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):
<SPAN class="comment token">// add an editable featurelayer from portal</SPAN>
Layer<SPAN class="punctuation token">.</SPAN><SPAN class="token function">fromPortalItem</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
portalItem<SPAN class="punctuation token">:</SPAN> <SPAN class="punctuation token">{</SPAN> <SPAN class="comment token">// autocasts as new PortalItem()</SPAN>
id<SPAN class="punctuation token">:</SPAN> <SPAN class="string token">"511b97fc0d364367b127f8ba5c89ad13"</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN><SPAN class="token function">then</SPAN><SPAN class="punctuation token">(</SPAN>addLayer<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">.</SPAN><SPAN class="keyword token">catch</SPAN><SPAN class="punctuation token">(</SPAN>handleLayerLoadError<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token function">setupEditing</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="token function">setupView</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">function</SPAN> <SPAN class="token function">addLayer</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
featureLayer <SPAN class="operator token">=</SPAN> layer<SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>layer<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>vs.
<SPAN class="keyword token">var</SPAN> lineSample <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">FeatureLayer</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN>
url<SPAN class="punctuation token">:</SPAN> <SPAN class="string token"><SPAN>"</SPAN><A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fsampleserver6.arcgisonline.com%2Farcgis%2Frest%2Fservices%2FWater_Network%2FFeatureServer%2F3" target="_blank">http://sampleserver6.arcgisonline.com/arcgis/rest/services/Water_Network/FeatureServer/3</A><SPAN>"</SPAN></SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
map<SPAN class="punctuation token">.</SPAN><SPAN class="token function">add</SPAN><SPAN class="punctuation token">(</SPAN>lineSample<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>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