<?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: ArcGIS Pro Attribute Rule to pass a value from child to parent in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167859#M54433</link>
    <description>&lt;P&gt;You're missing a step.&lt;/P&gt;&lt;P&gt;You return the first entry of the filtered feature set, which is the first inspection for that asset.&lt;/P&gt;&lt;P&gt;What you want to do:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;load the feature set and filter it&lt;/LI&gt;&lt;LI&gt;sort the related features by date, descending&lt;/LI&gt;&lt;LI&gt;return the first feature&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Foreign key in child table
var fk = $feature.GUID

//Load all inspections of the feature
var inspections = FeatureSetByName($datastore, "CHILD_TABLE_NAME",['GUID'],false)
var related_inspections = Filter(inspections, 'GUID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/225383"&gt;@fk&lt;/a&gt;')

// (if you have a relationship class, you can also do it like this)
var related_inspections = FeatureSetByRelationshipName($feature, "RelationshipName", ["GUID"], false)

// (also, you have a trigger on delete. if you delete an inspection, it will
// still be in the table when the rule is executed, so you should filter it out:)
if($editcontext.editType == "DELETE") {
    var pk = $feature.PrimaryKeyOfChildTable
    related_inspections = Filter(related_inspections, "PrimaryKeyOfChildTable &amp;lt;&amp;gt; @pk")
}

//Filter the most recent inspection date of the feature
var last_inspection = First(OrderBy(related_inspections, "DATE_INSPECTION DESC"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Apr 2022 09:41:25 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-04-26T09:41:25Z</dc:date>
    <item>
      <title>ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167830#M54430</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I have an ArcGIS geodatabase with a parent feature class related to a child stand alone table containing the various inspections made on each parent feature. Primary key is GlobalID and foreign key is GUID.&lt;/P&gt;&lt;P&gt;In ArcGIS Pro, I'm trying to edit an attribute rule to automatically populate a LAST_DATE_INSPECTION field in the parent feature class with the most recent inspection (DATE_INSPECTION field in the child table).&lt;/P&gt;&lt;P&gt;The code I did is only updating the parent LAST_DATE_INSPECTION field with the first inserted inspection date of the child table, not the most recent date. Looks like my filter isn't working.&lt;/P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MarkovicMaja_0-1650957959037.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/39837i99B26843B68578C9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MarkovicMaja_0-1650957959037.png" alt="MarkovicMaja_0-1650957959037.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    // calculation attribute rule on child table, field DATE_INSPECTION
    // triggers: Insert, Update, Delete

    //Foreign key in child table
    var fk = $feature.GUID

    //Load all inspections of the feature
    var related_inspection = FeatureSetByName($datastore, "CHILD_TABLE_NAME",['GUID'],false)

    //Filter the most recent inspection date of the feature
    var last_inspection = First(Filter(related_inspection, 'GUID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/225383"&gt;@fk&lt;/a&gt;'))

    //Return nothing if no date found
    if(IsEmpty(last_inspection)){
    return ;
    }

    //Updating DATE_INSPECTION field in parent feature class
    return {
    "result": fk,
         "edit": [{
            "className" : "PARENT_FC_NAME",
               "updates": [{
                 //selecting the parent feature to update
                 "GlobalID" : last_inspection.GUID,
                 //Update the LAST_DATE_INSPECTION field in parent feature class 
                 "attributes" : {'LAST_DATE_INSPECTION': last_inspection.DATE_INSPECTION
    }
                           }]
                  }]    
    };&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 08:56:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167830#M54430</guid>
      <dc:creator>mmarkovic</dc:creator>
      <dc:date>2022-04-26T08:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167859#M54433</link>
      <description>&lt;P&gt;You're missing a step.&lt;/P&gt;&lt;P&gt;You return the first entry of the filtered feature set, which is the first inspection for that asset.&lt;/P&gt;&lt;P&gt;What you want to do:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;load the feature set and filter it&lt;/LI&gt;&lt;LI&gt;sort the related features by date, descending&lt;/LI&gt;&lt;LI&gt;return the first feature&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Foreign key in child table
var fk = $feature.GUID

//Load all inspections of the feature
var inspections = FeatureSetByName($datastore, "CHILD_TABLE_NAME",['GUID'],false)
var related_inspections = Filter(inspections, 'GUID = &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/225383"&gt;@fk&lt;/a&gt;')

// (if you have a relationship class, you can also do it like this)
var related_inspections = FeatureSetByRelationshipName($feature, "RelationshipName", ["GUID"], false)

// (also, you have a trigger on delete. if you delete an inspection, it will
// still be in the table when the rule is executed, so you should filter it out:)
if($editcontext.editType == "DELETE") {
    var pk = $feature.PrimaryKeyOfChildTable
    related_inspections = Filter(related_inspections, "PrimaryKeyOfChildTable &amp;lt;&amp;gt; @pk")
}

//Filter the most recent inspection date of the feature
var last_inspection = First(OrderBy(related_inspections, "DATE_INSPECTION DESC"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 09:41:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167859#M54433</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-04-26T09:41:25Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167874#M54435</link>
      <description>&lt;P&gt;Wonderful ! It works perfectly! Thank you for the "delete trigger" script, very useful&lt;/P&gt;</description>
      <pubDate>Tue, 26 Apr 2022 11:33:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1167874#M54435</guid>
      <dc:creator>mmarkovic</dc:creator>
      <dc:date>2022-04-26T11:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290957#M69345</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I'm looking to replicate this but for a simple Yes/No attribute field called 'Action_reqd'. All steps seem to be working and the code validates fine, however when updating a child record, I'm getting the "Update table row failed. Invalid column value [Invalid column value] [Action_reqd]"&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PDNPAGIS_0-1684485504899.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/71135iB8992139B301FFBC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PDNPAGIS_0-1684485504899.png" alt="PDNPAGIS_0-1684485504899.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm not sure how to resolve - any pointers gratefully recevived &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 08:39:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290957#M69345</guid>
      <dc:creator>PDNPAGIS</dc:creator>
      <dc:date>2023-05-19T08:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290977#M69350</link>
      <description>&lt;P&gt;Please post the rule your code.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1677736512957.png" style="width: 546px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64138iBB0E7839D9513E0F/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_0-1677736512957.png" alt="JohannesLindner_0-1677736512957.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1677736529803.png" style="width: 661px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64139i1EE5AE3E3AEE8247/image-size/large?v=v2&amp;amp;px=999" role="button" title="JohannesLindner_1-1677736529803.png" alt="JohannesLindner_1-1677736529803.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 10:47:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290977#M69350</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-05-19T10:47:14Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Attribute Rule to pass a value from child to parent</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290991#M69352</link>
      <description>&lt;P&gt;Hello, thanks for the reply - my code is as per below&lt;/P&gt;&lt;P&gt;Parent table = Asset_Car_Park&lt;/P&gt;&lt;P&gt;Child table = Asset_Site_External_Inspection&lt;/P&gt;&lt;P&gt;I'm trying to update the parent table Action_reqd field with the Action_reqd record from the latest inspection survey in the related child table&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Foreign key in child table
var fk = $feature.parentglobalid
if (IsEmpty(fk))
    return fk;

fk = Upper(fk);

//Load all inspections of the feature
var inspections = FeatureSetByName($datastore, "Spatial.PDNPA_GEO.Asset_Site_External_Inspection",['parentglobalid', 'Action_reqd'],false)
var related_inspections = Filter(inspections, 'parentglobalid = ')

// (also, you have a trigger on delete. if you delete an inspection, it will
// still be in the table when the rule is executed, so you should filter it out:)

if($editcontext.editType == "DELETE") {
    var pk = $feature.GlobalID
    related_inspections = Filter(related_inspections, "GlobalID &amp;lt;&amp;gt; ")
}

//Filter the most recent inspection date of the feature
var last_inspection = First(OrderBy(related_inspections, "Inspection_date"))

    //Updating Action_reqd field in parent feature class
    return {
    'result': fk,
         'edit': [{
            'className' : "Spatial.PDNPA_GEO.Asset_Car_Park",
               'updates': [{
                 //selecting the parent feature to update
                 'GlobalID' : last_inspection.parentglobalid,
                 //Update the Action_reqd field in parent feature class 
                 'attributes' : {"Action_reqd": last_inspection.Action_reqd
    }
                           }]
                  }]
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 19 May 2023 12:19:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-attribute-rule-to-pass-a-value-from/m-p/1290991#M69352</guid>
      <dc:creator>PDNPAGIS</dc:creator>
      <dc:date>2023-05-19T12:19:05Z</dc:date>
    </item>
  </channel>
</rss>

