<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get fields from featureLayer created from rest service? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1077266#M73795</link>
    <description>&lt;P&gt;Try to ensure the layer is loaded:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;featureLayer.load().then(() =&amp;gt; {
  console.log(featureLayer.title, featureLayer.fields);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jul 2021 15:09:39 GMT</pubDate>
    <dc:creator>JohnGrayson</dc:creator>
    <dc:date>2021-07-09T15:09:39Z</dc:date>
    <item>
      <title>Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/245388#M22713</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to figure out a good way to retrieve the fields from an ArcGIS REST service. I first create a FeatureLayer from the a feature server url. When I console.log the feature layer, I see that it has fields, but when I try to console.log(featureLayer.fields) it is just null.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need the field information to create a popup template, but I am trying to find a way to avoid having to hard-code the field information. What is a good way of going about this?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="doctype token"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;html&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;lang&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;en&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;head&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;meta&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;charset&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;UTF-8&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;title&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;Document&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;title&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="language-css style token"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;style&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
        &lt;SPAN class="selector token"&gt;html,
        body,
        #viewDiv&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
            &lt;SPAN class="property token"&gt;padding&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 0&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
            &lt;SPAN class="property token"&gt;margin&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 0&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
            &lt;SPAN class="property token"&gt;height&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 100%&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
            &lt;SPAN class="property token"&gt;width&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; 100%&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;style&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;link&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;rel&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;stylesheet&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;href&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;https://js.arcgis.com/4.13/esri/css/main.css&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="language-javascript script token"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;script&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;src&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;https://js.arcgis.com/4.13/&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;script&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;head&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;body&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;div&lt;/SPAN&gt; &lt;SPAN class="attr-name token"&gt;id&lt;/SPAN&gt;&lt;SPAN class="attr-value token"&gt;&lt;SPAN class="punctuation token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;viewDiv&lt;SPAN class="punctuation token"&gt;"&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;div&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="language-javascript script token"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;&lt;/SPAN&gt;script&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
    &lt;SPAN class="token function"&gt;require&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/Map"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/views/MapView"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/widgets/Legend"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/PopupTemplate"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/layers/FeatureLayer"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
        &lt;SPAN class="string token"&gt;"esri/Graphic"&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; MapView&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Legend&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; PopupTemplate&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; FeatureLayer&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Graphic&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;

        &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;Map&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
            basemap&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"gray"&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

        &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; view &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;MapView&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
            container&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"viewDiv"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;
            map&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; map
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

        &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; featureLayer &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;new&lt;/SPAN&gt; &lt;SPAN class="token class-name"&gt;FeatureLayer&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
            url&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"https://services.arcgis.com/V6ZHFr6zdgNZuVG0/ArcGIS/rest/services/earthquakes_geojson/FeatureServer/0"&lt;/SPAN&gt;
        &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

        console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
        console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;

        &lt;SPAN class="comment token"&gt;// add the layer to the map&lt;/SPAN&gt;
        map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;add&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;script&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;body&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;
&lt;SPAN class="token tag"&gt;&lt;SPAN class="token tag"&gt;&lt;SPAN class="punctuation token"&gt;&amp;lt;/&lt;/SPAN&gt;html&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:14:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/245388#M22713</guid>
      <dc:creator>VincentLantaca1</dc:creator>
      <dc:date>2021-12-11T12:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/245389#M22714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have to wait until the feature layer is ready. You're trying to access its information before it's been created.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;featureLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;when&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureLayer&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;featureLayer&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;fields&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 12:14:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/245389#M22714</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-12-11T12:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1077174#M73786</link>
      <description>&lt;P&gt;when doesn't exist on the featureLayer. I am getting an error whenever it is about to fire.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 11:30:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1077174#M73786</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-07-09T11:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1077266#M73795</link>
      <description>&lt;P&gt;Try to ensure the layer is loaded:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;featureLayer.load().then(() =&amp;gt; {
  console.log(featureLayer.title, featureLayer.fields);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jul 2021 15:09:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1077266#M73795</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-07-09T15:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092608#M74416</link>
      <description>&lt;P&gt;Doesn't work. I am getting the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;TypeError: featureLayer.load is not a function
at dno_presenter.js?wab_dv=2.20:217
at LayerNode.js?wab_dv=2.20:127
at Object.traversal (LayerInfo.js?wab_dv=2.20:156)
at Object.traversal (LayerNode.js?wab_dv=2.20:126)
at Object._traversal (LayerStructure.js?wab_dv=2.20:124)
at Object.traversal (LayerStructure.js?wab_dv=2.20:146)
at Object.initLayers (dno_presenter.js?wab_dv=2.20:212)
at Object.initializeLayersWithFields (dno_presenter.js?wab_dv=2.20:494)
at Object.initComponents (dno_presenter.js?wab_dv=2.20:80)
at Object.initPresenter (Widget.js?wab_dv=2.20:22)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code&lt;/STRONG&gt;:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.layerStructure.traversal((layerNode) =&amp;gt; {
                        console.log("layerNode", layerNode);
                        let featureLayerUrl = layerNode?._layerInfo?.layerObject?.url;
                        let featureLayer = new FeatureLayer(featureLayerUrl);
                        console.log("featureLayer", featureLayer);
                        featureLayer.when(() =&amp;gt; {
                            console.log(featureLayer);
                            console.log(featureLayer.fields);
                        });
                    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 08:23:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092608#M74416</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-08-26T08:23:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092611#M74417</link>
      <description>&lt;P&gt;This shouldn't be accepted answer. I am getting the following exception:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;TypeError: featureLayer.when is not a function
    at dno_presenter.js?wab_dv=2.20:217
    at LayerNode.js?wab_dv=2.20:127
    at Object.traversal (LayerInfo.js?wab_dv=2.20:156)
    at Object.traversal (LayerNode.js?wab_dv=2.20:126)
    at Object._traversal (LayerStructure.js?wab_dv=2.20:124)
    at Object.traversal (LayerStructure.js?wab_dv=2.20:146)
    at Object.initLayers (dno_presenter.js?wab_dv=2.20:212)
    at Object.initializeLayersWithFields (dno_presenter.js?wab_dv=2.20:495)
    at Object.initComponents (dno_presenter.js?wab_dv=2.20:80)
    at Object.initPresenter (Widget.js?wab_dv=2.20:22)&lt;/LI-CODE&gt;&lt;P&gt;&lt;STRONG&gt;Code&lt;/STRONG&gt;:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.layerStructure.traversal((layerNode) =&amp;gt; {
                        console.log("layerNode", layerNode);
                        let featureLayerUrl = layerNode?._layerInfo?.layerObject?.url;
                        let featureLayer = new FeatureLayer(featureLayerUrl);
                        console.log("featureLayer", featureLayer);
                        featureLayer.when(() =&amp;gt; {
                            console.log(featureLayer);
                            console.log(featureLayer.fields);
                        });
                    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 08:22:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092611#M74417</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-08-26T08:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092721#M74427</link>
      <description>&lt;P&gt;Q: did you try my suggestion of waiting for the layer to loaded first?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;featureLayer.load().then(() =&amp;gt; {
  console.log(featureLayer.title, featureLayer.fields);
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:16:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092721#M74427</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-08-26T15:16:18Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092724#M74428</link>
      <description>&lt;P&gt;Yes, both load() and then() and when() are methods that other developers including you have suggested but the console spits out an error messaging saying that those doesn't exist on the featureLayer. When I log out the featureLayer to the console, I can see that there is a property called _fields of the type Proxy. If the web map retrieves layers from a FeatureServer REST service, I am able to fetch the _fields property and deconstruct the Proxy object, however, if it is a layer from a MapServer REST service, it is not possible.&amp;nbsp;&lt;/P&gt;&lt;P&gt;We're running our GIS on an ArcGIS Enterprise.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My thread:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-web-appbuilder-questions/fetch-proxy-object-fields-from-featurelayer-object/td-p/1092618" target="_blank"&gt;https://community.esri.com/t5/arcgis-web-appbuilder-questions/fetch-proxy-object-fields-from-featurelayer-object/td-p/1092618&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:19:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092724#M74428</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-08-26T15:19:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092730#M74430</link>
      <description>&lt;P&gt;Q: do you have a &lt;EM&gt;very simple&lt;/EM&gt; codepen (or similar) so we can experience the issue?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:26:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092730#M74430</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-08-26T15:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092736#M74431</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;this.layerStructure.traversal((layerNode) =&amp;gt; {
                        let layerServiceUrl = layerNode?._layerInfo?.layerObject?.url;
                        let featureLayer = new FeatureLayer(layerServiceUrl);
// your suggestion
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have implemented your suggestion on line 4, but it throws an error saying that load, then and when doesn't exist. I checked the docs, and they aren't listed there:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html" target="_blank"&gt;https://developers.arcgis.com/javascript/3/jsapi/featurelayer-amd.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Access to the layers of the map through LayerStructure:&amp;nbsp;&lt;A href="https://developers.arcgis.com/web-appbuilder/api-reference/layerstructure.htm" target="_blank"&gt;https://developers.arcgis.com/web-appbuilder/api-reference/layerstructure.htm&lt;/A&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;"jimu/LayerStructure"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;You can paste the code in your postCreate method, after importing the above in your AMD.&amp;nbsp; Your web map needs to import an ArcGIS REST Service of the type: MapServer, as rest services of the type FeatureServer can provide _fields through a proxy object:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diaconori_0-1629992408344.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/21800i26A764274E4FFED0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diaconori_0-1629992408344.png" alt="diaconori_0-1629992408344.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Not sure if it is different on a plain webpage that you're calling the ArcGIS JavaScript API from, but it seems to be vastly different when you're running WAB on ArcGIS Enterprise.&amp;nbsp;&lt;BR /&gt;Where to import on your web map:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="diaconori_1-1629992532474.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/21801i577F7F7E9B7C57F5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="diaconori_1-1629992532474.png" alt="diaconori_1-1629992532474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:45:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092736#M74431</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-08-26T15:45:04Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092740#M74432</link>
      <description>&lt;P&gt;And here's a quick CodePen using the service you mention above:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://codepen.io/john-grayson/pen/MWowbgX" target="_blank"&gt;https://codepen.io/john-grayson/pen/MWowbgX&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:43:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092740#M74432</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-08-26T15:43:30Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092748#M74435</link>
      <description>&lt;P&gt;I see, so your question is about the WAB and JS API 3.x?&amp;nbsp; All the suggestions I've seen here are for the JS API 4.x because that is what the original question was about.&amp;nbsp; You should consider creating a new question specific to your use-case as it's very different from this one.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:52:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092748#M74435</guid>
      <dc:creator>JohnGrayson</dc:creator>
      <dc:date>2021-08-26T15:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Get fields from featureLayer created from rest service?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092749#M74436</link>
      <description>&lt;P&gt;Yes, we're running WAB and JS API 3.x. (deleted the comment above as I intended it to be a placeholder while trying to send you some code).&lt;/P&gt;&lt;P&gt;I see. My mistake. I thought that the structure of the FeatureLayer class follows the same data model across the version 3 and 4. Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Aug 2021 15:54:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-fields-from-featurelayer-created-from-rest/m-p/1092749#M74436</guid>
      <dc:creator>diaconori</dc:creator>
      <dc:date>2021-08-26T15:54:50Z</dc:date>
    </item>
  </channel>
</rss>

