<?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 Get Feature Layer with Dashboard Data expression in ArcGIS Online Developers Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-developers-questions/get-feature-layer-with-dashboard-data-expression/m-p/1303683#M1248</link>
    <description>&lt;P&gt;I am trying to create a Data Expression within an AGO Dashboard (current dashboard, not classic) serial chart and I am having trouble getting a layer so I cna build an expression around it. I have seen numerous examples using the following example:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;// Represents the ArcGIS Online portal instance&lt;/SPAN&gt;&lt;SPAN&gt;var &lt;BR /&gt;agol = Portal("https://www.arcgis.com");&lt;/SPAN&gt;
&lt;SPAN&gt;&lt;BR /&gt;// references a layer with its ID from a specified portal instance&lt;/SPAN&gt;&lt;SPAN&gt;var &lt;BR /&gt;layer = FeatureSetByPortalItem(agol, "7b1fb95ab77f40bf8aa09c8b59045449", 0, ["*"], false);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I have ran the expression using my own organizational account and item id but it returns NULL:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelMacRae_0-1687909035494.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74318i0222F6FF86978086/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelMacRae_0-1687909035494.png" alt="MichaelMacRae_0-1687909035494.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I believe the issue is, I do not have ArcGIS Portal, so I don't believe I can use the &lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt; function.&lt;/P&gt;&lt;P&gt;I have tried some of the other functions (i.e.&amp;nbsp;FeatureSetById,&amp;nbsp;FeatureSetByName, etc) to get my feature service, but I keep getting errors. It does seem to recognize the map in my dashboard using '$map'. I have also tried '$datastore'.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelMacRae_1-1687909309354.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74320i60ACBDF3985D9FA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelMacRae_1-1687909309354.png" alt="MichaelMacRae_1-1687909309354.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am at a bit of a loss. I have no idea how to get a feature service into my expression to I can build more expression. Any suggestions as to how to do this?&lt;/P&gt;</description>
    <pubDate>Wed, 28 Jun 2023 00:20:54 GMT</pubDate>
    <dc:creator>MichaelMacRae</dc:creator>
    <dc:date>2023-06-28T00:20:54Z</dc:date>
    <item>
      <title>Get Feature Layer with Dashboard Data expression</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/get-feature-layer-with-dashboard-data-expression/m-p/1303683#M1248</link>
      <description>&lt;P&gt;I am trying to create a Data Expression within an AGO Dashboard (current dashboard, not classic) serial chart and I am having trouble getting a layer so I cna build an expression around it. I have seen numerous examples using the following example:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;// Represents the ArcGIS Online portal instance&lt;/SPAN&gt;&lt;SPAN&gt;var &lt;BR /&gt;agol = Portal("https://www.arcgis.com");&lt;/SPAN&gt;
&lt;SPAN&gt;&lt;BR /&gt;// references a layer with its ID from a specified portal instance&lt;/SPAN&gt;&lt;SPAN&gt;var &lt;BR /&gt;layer = FeatureSetByPortalItem(agol, "7b1fb95ab77f40bf8aa09c8b59045449", 0, ["*"], false);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;I have ran the expression using my own organizational account and item id but it returns NULL:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelMacRae_0-1687909035494.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74318i0222F6FF86978086/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelMacRae_0-1687909035494.png" alt="MichaelMacRae_0-1687909035494.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I believe the issue is, I do not have ArcGIS Portal, so I don't believe I can use the &lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt; function.&lt;/P&gt;&lt;P&gt;I have tried some of the other functions (i.e.&amp;nbsp;FeatureSetById,&amp;nbsp;FeatureSetByName, etc) to get my feature service, but I keep getting errors. It does seem to recognize the map in my dashboard using '$map'. I have also tried '$datastore'.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MichaelMacRae_1-1687909309354.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/74320i60ACBDF3985D9FA5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MichaelMacRae_1-1687909309354.png" alt="MichaelMacRae_1-1687909309354.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I am at a bit of a loss. I have no idea how to get a feature service into my expression to I can build more expression. Any suggestions as to how to do this?&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 00:20:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/get-feature-layer-with-dashboard-data-expression/m-p/1303683#M1248</guid>
      <dc:creator>MichaelMacRae</dc:creator>
      <dc:date>2023-06-28T00:20:54Z</dc:date>
    </item>
    <item>
      <title>Re: Get Feature Layer with Dashboard Data expression</title>
      <link>https://community.esri.com/t5/arcgis-online-developers-questions/get-feature-layer-with-dashboard-data-expression/m-p/1304258#M1250</link>
      <description>&lt;P&gt;SO, I figured out where I was going wrong. I am fairly new to Arcade, but have a solid scripting background, so I shouldn't have missed some things.&lt;/P&gt;&lt;P&gt;First, the FeatureSetByPortalItem function does work, regardless whether or not you have ArcGIS Portal. It's just a function call for an item in your given portal. So, the following works:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;agol = Portal("https://www.arcgis.com");&lt;BR /&gt;layer = FeatureSetByPortalItem(agol, "7b1fb95ab77f40bf8aa09c8b59045449", 0, ["*"], false);&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Next, I was receiving NULL because I did not return the item. Needed to add&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;return layer&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;Finally, after returning the item, I was getting weird behavior. It was returning a table that was not associated with the item ID. Like...a totally different table! I tripled checked the item ID and event tired some random ones fro data my organization holds. Still, the wrong table each time. Turned out, you need to add the layer ID after the item ID.&amp;nbsp; So, I had to change the &lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt; itemID from &lt;STRONG&gt;0&lt;/STRONG&gt; to the &lt;EM&gt;id of my layer. &lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I wasn't coming across a lot of documentation explaining how to use Data Expressions. All of the examples showed the &lt;SPAN&gt;FeatureSetByPortalItem&lt;/SPAN&gt;, but none of them explained why. Intuitively, I just thought I needed a portal account. In the end, all I wanted to do was reference my organizational data directly, without refering a map or layer first.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jun 2023 22:58:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-developers-questions/get-feature-layer-with-dashboard-data-expression/m-p/1304258#M1250</guid>
      <dc:creator>MichaelMacRae</dc:creator>
      <dc:date>2023-06-28T22:58:48Z</dc:date>
    </item>
  </channel>
</rss>

