<?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 expression - Related Table in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246363#M49676</link>
    <description>&lt;LI-CODE lang="javascript"&gt;// load the related rows, using one of two ways:

// either load the featureset and filter it (replace the key field names)
var related_fs = FeaturesetByPortalItem(...)
var key_value = $feature.PrimaryKey
var related_rows = Filter(related_fs, "ForeignKey = @key_value")

// or load only the related rows, using the name of the relationship class
var related_rows = FeaturesetByRelationshipName($feature, "RelationshipName")

// get the latest survey
var latest_survey = First(OrderBy(related_rows, "SurveyDate DESC"))

// return a default value if no survey was found
if(latest_survey == null) {
    return "not surveyed yet"
}

// if all damage types are non-existent, the palm is undamaged
if(latest_survey.SpearDamage == "No" &amp;amp;&amp;amp; latest_survey.BoreHoles == "No" &amp;amp;&amp;amp; latest_survey.InnerFrondsDamaged == 0 &amp;amp;&amp;amp; latest_survey.OuterFrondsDamaged == 0) {
    return "No"
}

// else it is damaged
return "Yes"&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 09 Jan 2023 07:59:33 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2023-01-09T07:59:33Z</dc:date>
    <item>
      <title>Arcade expression - Related Table</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246331#M49674</link>
      <description>&lt;P&gt;Hi all! I am somewhat new to using Arcade and need some help to populate a field based on the most recent related record.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The field I would like to populate is CRNT_DAMAGE from the newest related record "Individual Palm Damage Survey" based on the field "SurveyDate".&amp;nbsp; The condition I would like met is if "SpearDamage" and "BoreHoles" == No as well as "InnerFrondsDamaged" and "OuterFrondsDamaged" == 0, then the return value would be "No" for CRNT_Damage.&amp;nbsp; All else would return "Yes".&lt;/P&gt;&lt;P&gt;Please comment bellow if you have suggestions or can refer me to a similar expression.&lt;/P&gt;&lt;P&gt;Thank you all!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled4.jpg" style="width: 569px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/59937i59B72F6555249136/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled4.jpg" alt="Untitled4.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Jan 2023 20:53:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246331#M49674</guid>
      <dc:creator>crbdata</dc:creator>
      <dc:date>2023-01-08T20:53:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression - Related Table</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246363#M49676</link>
      <description>&lt;LI-CODE lang="javascript"&gt;// load the related rows, using one of two ways:

// either load the featureset and filter it (replace the key field names)
var related_fs = FeaturesetByPortalItem(...)
var key_value = $feature.PrimaryKey
var related_rows = Filter(related_fs, "ForeignKey = @key_value")

// or load only the related rows, using the name of the relationship class
var related_rows = FeaturesetByRelationshipName($feature, "RelationshipName")

// get the latest survey
var latest_survey = First(OrderBy(related_rows, "SurveyDate DESC"))

// return a default value if no survey was found
if(latest_survey == null) {
    return "not surveyed yet"
}

// if all damage types are non-existent, the palm is undamaged
if(latest_survey.SpearDamage == "No" &amp;amp;&amp;amp; latest_survey.BoreHoles == "No" &amp;amp;&amp;amp; latest_survey.InnerFrondsDamaged == 0 &amp;amp;&amp;amp; latest_survey.OuterFrondsDamaged == 0) {
    return "No"
}

// else it is damaged
return "Yes"&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 09 Jan 2023 07:59:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246363#M49676</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-01-09T07:59:33Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression - Related Table</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246598#M49686</link>
      <description>&lt;P&gt;Johannes- this is awesome, I'm looking forward to implementing this expression!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2023 20:26:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1246598#M49686</guid>
      <dc:creator>crbdata</dc:creator>
      <dc:date>2023-01-09T20:26:36Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression - Related Table</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1247070#M49704</link>
      <description>&lt;P&gt;Hi Johannes-&lt;/P&gt;&lt;P&gt;Upon testing the arcade expression, this was the error message received. Do you know what the error is for?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;"Execution error - Line : 2, 26: Invalid parameter"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2023 22:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1247070#M49704</guid>
      <dc:creator>CRBData1</dc:creator>
      <dc:date>2023-01-10T22:31:40Z</dc:date>
    </item>
    <item>
      <title>Re: Arcade expression - Related Table</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1247165#M49712</link>
      <description>&lt;P&gt;Judging from the fields, you are writing this expression in the palm survey table. But it should be written for the palm layer.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 10:16:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/arcade-expression-related-table/m-p/1247165#M49712</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-01-11T10:16:28Z</dc:date>
    </item>
  </channel>
</rss>

