<?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: Arcade Calculated Expression -  Attribute from related record in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309582#M53452</link>
    <description>&lt;P&gt;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 to return the related records for a feature.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var related = FeatureSetByRelationshipName($feature, 'your relationship name');

if (Count(related) &amp;gt; 0) {
  var record = First(related);
  return record.Status;
}&lt;/LI-CODE&gt;&lt;P&gt;You'll need to know the Relationship name, which is found in the feature layer's service page (like this one)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="relationships.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75743iCED44F6ADC7A9858/image-size/medium?v=v2&amp;amp;px=400" role="button" title="relationships.png" alt="relationships.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jul 2023 15:43:57 GMT</pubDate>
    <dc:creator>KenBuja</dc:creator>
    <dc:date>2023-07-19T15:43:57Z</dc:date>
    <item>
      <title>Arcade Calculated Expression -  Attribute from related record</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309529#M53451</link>
      <description>&lt;P&gt;I have a polygon hosted feature layer along with a related table in ArcGIS Online. The layer and table are related via GlobalID and ParentGuid.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm attempted to add a calculated expression through forms on map viewer, and what i'm trying to achieve is that when a related record is added, the surveyor must add a "Status" on the related record. I'd then like the calculated expression to be against the "Status" field on the feature layer, and when the related record is added, the following expression will update the "Status" on the feature layer of the "Status" on the related record.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My expression is successfully executing but is always returning null, which I assume means it can't find a match between GlobalID and ParentGuid, but a quick check on the table reveals there are matches and this can also be proven by clicking on the popup to reveal the related records.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="sql"&gt;var relatedRecords = FeatureSetByName($datastore, 'Test_Log', ['Status'], false);
var parentId = $feature.GlobalID;

for (var record in relatedRecords) {
    if (record.ParentGuid == parentId) {
        return record.Status;
    }
}

return null;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 14:31:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309529#M53451</guid>
      <dc:creator>RiainGarcia</dc:creator>
      <dc:date>2023-07-19T14:31:32Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculated Expression -  Attribute from related record</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309582#M53452</link>
      <description>&lt;P&gt;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 to return the related records for a feature.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var related = FeatureSetByRelationshipName($feature, 'your relationship name');

if (Count(related) &amp;gt; 0) {
  var record = First(related);
  return record.Status;
}&lt;/LI-CODE&gt;&lt;P&gt;You'll need to know the Relationship name, which is found in the feature layer's service page (like this one)&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="relationships.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/75743iCED44F6ADC7A9858/image-size/medium?v=v2&amp;amp;px=400" role="button" title="relationships.png" alt="relationships.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jul 2023 15:43:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309582#M53452</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-07-19T15:43:57Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculated Expression -  Attribute from related record</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309984#M53475</link>
      <description>&lt;P&gt;Genius! Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 12:22:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1309984#M53475</guid>
      <dc:creator>RiainGarcia</dc:creator>
      <dc:date>2023-07-20T12:22:38Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculated Expression -  Attribute from related record</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1333090#M54796</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/433759"&gt;@RiainGarcia&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I think I'm trying to do something similar to you, but I'm not quite following your process. Is your calculated expression being applied to a field in your parent feature or the related table? If it is on the parent feature, how is it being triggered when a related record is added?&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 19:54:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1333090#M54796</guid>
      <dc:creator>marksm_macomb</dc:creator>
      <dc:date>2023-09-27T19:54:11Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade Calculated Expression -  Attribute from related record</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1558199#M62343</link>
      <description>&lt;P&gt;I copied this same script, but it still returns null even if there are related records.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Dec 2024 18:17:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-calculated-expression-attribute-from/m-p/1558199#M62343</guid>
      <dc:creator>Krocha</dc:creator>
      <dc:date>2024-12-09T18:17:32Z</dc:date>
    </item>
  </channel>
</rss>

