<?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 Update a parent feature in a relationship when a new child record is inserted in ArcGIS Online Questions</title>
    <link>https://community.esri.com/t5/arcgis-online-questions/update-a-parent-feature-in-a-relationship-when-a/m-p/1143794#M44374</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I tried to following this &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/UpdateParentFeature.md" target="_self"&gt;post&lt;/A&gt; to update last survey date of a parent feature in a relationship when a new child record is inserted using "&lt;SPAN&gt;Add Attribute Rule geoprocessing tool" in ArcGIS Pro.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the Arcade expression I put in attribute rule. It cannot recognize 'survey_date' field in child record. I cannot figure out how to fix it.&amp;nbsp;&lt;SPAN&gt;Any suggestions on how to fix this are much appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;________________________________________________________________________________________________&lt;/P&gt;&lt;P&gt;// This rule will update an attribute in the parent feature&lt;/P&gt;&lt;P&gt;// Store the parent feature global from the key field in the relationship&lt;BR /&gt;var parent_id = $feature.GlobalID;&lt;BR /&gt;if (IsEmpty(parent_id))&lt;BR /&gt;return parent_id;&lt;/P&gt;&lt;P&gt;// force to upper as the sql is case sensitive&lt;BR /&gt;parent_id = Upper(parent_id);&lt;/P&gt;&lt;P&gt;// Using the GDB name, get the parent classes records and Global ID field&lt;BR /&gt;var parent_class = FeatureSetByName($datastore, "gsob_trees", ["GlobalID", 'date'], false);&lt;BR /&gt;// Filter the parent class for only related features&lt;BR /&gt;var parent_records = Filter(parent_class, "GlobalID = @parent_id");&lt;/P&gt;&lt;P&gt;var updates = [];&lt;BR /&gt;var i = 0;&lt;/P&gt;&lt;P&gt;// Loop through each feature, create a dict of the Global ID and the new date&lt;BR /&gt;for (var row in parent_records)&lt;BR /&gt;// updated Date from child record&lt;BR /&gt;{&lt;BR /&gt;updates[i++] = {&lt;BR /&gt;'Global ID': parent_id,&lt;BR /&gt;'attributes': {"date": $feature.survey_date}&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return the original value in the result parameter, as to not lost the entered value&lt;BR /&gt;// Using the edit parameter, return the class and list of updates&lt;BR /&gt;return {&lt;BR /&gt;'result': parent_id,&lt;BR /&gt;'edit': [&lt;BR /&gt;{'className': 'ParentLayer',&lt;BR /&gt;'updates': updates&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;};&lt;/P&gt;</description>
    <pubDate>Mon, 14 Feb 2022 19:39:21 GMT</pubDate>
    <dc:creator>Yi-ChinFang</dc:creator>
    <dc:date>2022-02-14T19:39:21Z</dc:date>
    <item>
      <title>Update a parent feature in a relationship when a new child record is inserted</title>
      <link>https://community.esri.com/t5/arcgis-online-questions/update-a-parent-feature-in-a-relationship-when-a/m-p/1143794#M44374</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I tried to following this &lt;A href="https://github.com/Esri/arcade-expressions/blob/master/attribute_rule_calculation/UpdateParentFeature.md" target="_self"&gt;post&lt;/A&gt; to update last survey date of a parent feature in a relationship when a new child record is inserted using "&lt;SPAN&gt;Add Attribute Rule geoprocessing tool" in ArcGIS Pro.&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is the Arcade expression I put in attribute rule. It cannot recognize 'survey_date' field in child record. I cannot figure out how to fix it.&amp;nbsp;&lt;SPAN&gt;Any suggestions on how to fix this are much appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;________________________________________________________________________________________________&lt;/P&gt;&lt;P&gt;// This rule will update an attribute in the parent feature&lt;/P&gt;&lt;P&gt;// Store the parent feature global from the key field in the relationship&lt;BR /&gt;var parent_id = $feature.GlobalID;&lt;BR /&gt;if (IsEmpty(parent_id))&lt;BR /&gt;return parent_id;&lt;/P&gt;&lt;P&gt;// force to upper as the sql is case sensitive&lt;BR /&gt;parent_id = Upper(parent_id);&lt;/P&gt;&lt;P&gt;// Using the GDB name, get the parent classes records and Global ID field&lt;BR /&gt;var parent_class = FeatureSetByName($datastore, "gsob_trees", ["GlobalID", 'date'], false);&lt;BR /&gt;// Filter the parent class for only related features&lt;BR /&gt;var parent_records = Filter(parent_class, "GlobalID = @parent_id");&lt;/P&gt;&lt;P&gt;var updates = [];&lt;BR /&gt;var i = 0;&lt;/P&gt;&lt;P&gt;// Loop through each feature, create a dict of the Global ID and the new date&lt;BR /&gt;for (var row in parent_records)&lt;BR /&gt;// updated Date from child record&lt;BR /&gt;{&lt;BR /&gt;updates[i++] = {&lt;BR /&gt;'Global ID': parent_id,&lt;BR /&gt;'attributes': {"date": $feature.survey_date}&lt;BR /&gt;};&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;// Return the original value in the result parameter, as to not lost the entered value&lt;BR /&gt;// Using the edit parameter, return the class and list of updates&lt;BR /&gt;return {&lt;BR /&gt;'result': parent_id,&lt;BR /&gt;'edit': [&lt;BR /&gt;{'className': 'ParentLayer',&lt;BR /&gt;'updates': updates&lt;BR /&gt;}&lt;BR /&gt;]&lt;BR /&gt;};&lt;/P&gt;</description>
      <pubDate>Mon, 14 Feb 2022 19:39:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-online-questions/update-a-parent-feature-in-a-relationship-when-a/m-p/1143794#M44374</guid>
      <dc:creator>Yi-ChinFang</dc:creator>
      <dc:date>2022-02-14T19:39:21Z</dc:date>
    </item>
  </channel>
</rss>

