<?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: Creating a Arcade expression in ArcGIS Enterprise Portal Questions</title>
    <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/creating-a-arcade-expression/m-p/1386202#M14682</link>
    <description>&lt;P&gt;You're supplying the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyid" target="_self"&gt;FeatureSetById&lt;/A&gt; function incorrect parameters, which would look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = FeatureSetById($map,'DemoLayerWM_1117', ['*'], true);&lt;/LI-CODE&gt;&lt;P&gt;It looks likes you should be using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem" target="_self"&gt;FeatureSetByPortalItem&lt;/A&gt;, which looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = FeatureSetByPortalItem(
  Portal('https://www.arcgis.com'),
  '7b1fb95ab77f40bf8aa09c8b59045449',
  0,
  ['Name', 'Count'],
  false
);&lt;/LI-CODE&gt;&lt;P&gt;If you have set up a relationship between the feature layer and the tables you can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyrelationshipname" target="_self"&gt;FeatureSetByRelationshipName&lt;/A&gt; function. This allows you to get there related records without having to loop through all the features.&lt;/P&gt;&lt;P&gt;Here's an example of retrieving the related records for a popup.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var rec = First(FeatureSetByRelationshipName($feature, "DCGIS.ITSPE", ['BIDNAME', 'BIDTOTALDUE', 'BIDCOLLECTED', 'BIDBALANCE']));
if (IsEmpty(rec.BIDNAME)) return 'Not a BID';
return `${rec.BIDNAME}
    • Total Due: ${Text(rec.BIDTOTALDUE, '$#,###.00')}
    • Collected: ${Text(rec.BIDCOLLECTED, '$#,###.00')}
    • Balance: ${Text(rec.BIDBALANCE, '$#,###.00')}`&lt;/LI-CODE&gt;&lt;P&gt;This example is uses a &lt;A href="https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/40" target="_self"&gt;public service&lt;/A&gt;, so you can examine how it uses the relationships.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="related.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95678i77E31FF1C9C28B40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="related.png" alt="related.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;related.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Fri, 23 Feb 2024 18:40:43 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2024-02-23T18:40:43Z</dc:date>
    <item>
      <title>Creating a Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/creating-a-arcade-expression/m-p/1386088#M14679</link>
      <description>&lt;P&gt;Currently, I am trying to write an Arcade expression. I have one feature layer that is related to three standalone tables. In this scenario, I am only using the feature layer "Layer" and one of the tables called "status". This feature layer is used in ArcGIS Field Maps where our construction and engineering teams can use and update project development while out in the field. When they update the status field in the status table, I want that to automatically update the status field in the feature layer. These two are related through the GlobalID in the status standalone table and the status_ID (which is a GUID) in the feature layer. Below is my script I created. I have tried so many different ways and I keep getting errors. I created a script in Python that works on Pro but I need something in Arcade that works on Map Viewer so I can configure the pop up. Here is my current Arcade script:&lt;/P&gt;&lt;P&gt;var layer = FeatureSetById('cc74c700497f4e64bbf9ffe157108c90', ["status", "GlobalID"]);&lt;BR /&gt;var table = FeatureSetById('cc74c700497f4e64bbf9ffe157108c90', ["status", "status_ID"]);&lt;/P&gt;&lt;P&gt;var updatedStatus = "No Match";&lt;/P&gt;&lt;P&gt;// Loop through features in the layer&lt;BR /&gt;for (var feature in layer.features) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var layerGlobalID = feature.attributes.GlobalID;&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; // Find corresponding record in the table&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; var matchingRecords = Filter(table, 'status_ID = @layerGlobalID');&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; if (Count(matchingRecords) &amp;gt; 0) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// Get the status value from the matching record&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var matchingStatus = First(matchingRecords).attributes.status;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Update the status field in the layer feature&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;feature.attributes.status = matchingStatus;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;updatedStatus = matchingStatus;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;return updatedStatus&lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 16:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/creating-a-arcade-expression/m-p/1386088#M14679</guid>
      <dc:creator>ColeShelley</dc:creator>
      <dc:date>2024-02-23T16:28:18Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a Arcade expression</title>
      <link>https://community.esri.com/t5/arcgis-enterprise-portal-questions/creating-a-arcade-expression/m-p/1386202#M14682</link>
      <description>&lt;P&gt;You're supplying the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyid" target="_self"&gt;FeatureSetById&lt;/A&gt; function incorrect parameters, which would look like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = FeatureSetById($map,'DemoLayerWM_1117', ['*'], true);&lt;/LI-CODE&gt;&lt;P&gt;It looks likes you should be using the &lt;A href="https://developers.arcgis.com/arcade/function-reference/portal_functions/#featuresetbyportalitem" target="_self"&gt;FeatureSetByPortalItem&lt;/A&gt;, which looks like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var features = FeatureSetByPortalItem(
  Portal('https://www.arcgis.com'),
  '7b1fb95ab77f40bf8aa09c8b59045449',
  0,
  ['Name', 'Count'],
  false
);&lt;/LI-CODE&gt;&lt;P&gt;If you have set up a relationship between the feature layer and the tables you can use the &lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyrelationshipname" target="_self"&gt;FeatureSetByRelationshipName&lt;/A&gt; function. This allows you to get there related records without having to loop through all the features.&lt;/P&gt;&lt;P&gt;Here's an example of retrieving the related records for a popup.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var rec = First(FeatureSetByRelationshipName($feature, "DCGIS.ITSPE", ['BIDNAME', 'BIDTOTALDUE', 'BIDCOLLECTED', 'BIDBALANCE']));
if (IsEmpty(rec.BIDNAME)) return 'Not a BID';
return `${rec.BIDNAME}
    • Total Due: ${Text(rec.BIDTOTALDUE, '$#,###.00')}
    • Collected: ${Text(rec.BIDCOLLECTED, '$#,###.00')}
    • Balance: ${Text(rec.BIDBALANCE, '$#,###.00')}`&lt;/LI-CODE&gt;&lt;P&gt;This example is uses a &lt;A href="https://maps2.dcgis.dc.gov/dcgis/rest/services/DCGIS_DATA/Property_and_Land_WebMercator/MapServer/40" target="_self"&gt;public service&lt;/A&gt;, so you can examine how it uses the relationships.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="related.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/95678i77E31FF1C9C28B40/image-size/medium?v=v2&amp;amp;px=400" role="button" title="related.png" alt="related.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;related.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 23 Feb 2024 18:40:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-enterprise-portal-questions/creating-a-arcade-expression/m-p/1386202#M14682</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2024-02-23T18:40:43Z</dc:date>
    </item>
  </channel>
</rss>

