<?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: Pull attributes from Related Table into Parent feature class in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1539403#M1579</link>
    <description>&lt;P&gt;Just add and OrderBy date to your featureset and call First on it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, do not assign this rule to a field, the return is better like this&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.Adoption_Status != "Approved") {
    return ;
}
var parent_id = $feature.GlobalID;
if (IsEmpty(parent_id)){
    return;
}
// Could use https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyrelationshipname also
var relatedTab = FeatureSetByName($datastore, "AAS_Adopters", ['GlobalID', 'Parent_GUID', 'Name', 'Email', 'Phone_Number'], false)
var relatedRec = First(OrderBy(Filter(relatedTab, 'Parent_GUID = @parent_id'),'&amp;lt;YOUR DATE FIELD&amp;gt; DESC'))
if (IsEmpty(relatedRec)){
    return;
}

return {
    "result": {
        "attributes": {
            "Adopted_By": relatedRec.Name,
            "Adopter_Contact_Email": relatedRec.Email,
            "Adopter_Contact_Number": relatedRec.Phone_Number
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;also, please post code as code snippet(javascript for arcade).&amp;nbsp; It really helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 17 Sep 2024 12:31:52 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2024-09-17T12:31:52Z</dc:date>
    <item>
      <title>Pull attributes from Related Table into Parent feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1538964#M1577</link>
      <description>&lt;P&gt;Issue: Im attempting to pull attributes from a related table into the parent feature class once a particular status has been chosen.&lt;/P&gt;&lt;P&gt;Details: Once a user selects the adoption status as "Approved", I need to retrieve the adopters name, email and phone number from the latest related record. (TEST DATA INCLUDED AS ATTACHMENT)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current Code:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;parent_id&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;$feature&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;GlobalID&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;IsEmpty&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;parent_id&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt; &lt;SPAN&gt;parent_id&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;relatedTab&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;FeatureSetByName&lt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sp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;"Adopter_Contact_Number"&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt;&lt;SPAN&gt;relatedRec&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;Phone_Number&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 16 Sep 2024 15:30:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1538964#M1577</guid>
      <dc:creator>JoeRob_AWPM</dc:creator>
      <dc:date>2024-09-16T15:30:47Z</dc:date>
    </item>
    <item>
      <title>Re: Pull attributes from Related Table into Parent feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1539403#M1579</link>
      <description>&lt;P&gt;Just add and OrderBy date to your featureset and call First on it.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, do not assign this rule to a field, the return is better like this&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby" target="_blank"&gt;https://developers.arcgis.com/arcade/function-reference/featureset_functions/#orderby&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if ($feature.Adoption_Status != "Approved") {
    return ;
}
var parent_id = $feature.GlobalID;
if (IsEmpty(parent_id)){
    return;
}
// Could use https://developers.arcgis.com/arcade/function-reference/featureset_functions/#featuresetbyrelationshipname also
var relatedTab = FeatureSetByName($datastore, "AAS_Adopters", ['GlobalID', 'Parent_GUID', 'Name', 'Email', 'Phone_Number'], false)
var relatedRec = First(OrderBy(Filter(relatedTab, 'Parent_GUID = @parent_id'),'&amp;lt;YOUR DATE FIELD&amp;gt; DESC'))
if (IsEmpty(relatedRec)){
    return;
}

return {
    "result": {
        "attributes": {
            "Adopted_By": relatedRec.Name,
            "Adopter_Contact_Email": relatedRec.Email,
            "Adopter_Contact_Number": relatedRec.Phone_Number
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;also, please post code as code snippet(javascript for arcade).&amp;nbsp; It really helps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 12:31:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1539403#M1579</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2024-09-17T12:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Pull attributes from Related Table into Parent feature class</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1539485#M1580</link>
      <description>&lt;P&gt;Thanks a lot for your response Mike. Will try and let you know of the results.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 14:33:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/pull-attributes-from-related-table-into-parent/m-p/1539485#M1580</guid>
      <dc:creator>JoeRob_AWPM</dc:creator>
      <dc:date>2024-09-17T14:33:11Z</dc:date>
    </item>
  </channel>
</rss>

