<?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: Create Attribute Rule that populates a date field in the feature class from the inspection date in the related table based on a condition in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269946#M774</link>
    <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response! It worked perfectly. I'm migrating a number of layers from AGOL to our new Enterprise.&amp;nbsp; In doing so, I'm trying to automate a number of steps.&amp;nbsp; I've completed four, and now with your help I have the fifth one completed.&amp;nbsp; I have two more to do.&amp;nbsp; I'll try to figure them out on my own and if I'm unsuccessful, I'll post to the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thank you so much!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Mar 2023 17:14:16 GMT</pubDate>
    <dc:creator>EricGlover3</dc:creator>
    <dc:date>2023-03-21T17:14:16Z</dc:date>
    <item>
      <title>Create Attribute Rule that populates a date field in the feature class from the inspection date in the related table based on a condition</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269552#M772</link>
      <description>&lt;P&gt;Hi ESRI Community,&lt;/P&gt;&lt;P&gt;I want to caveat this by stating that I’m a complete rookie to this.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a drainage network layer that consists of a feature class with a field that gets populated when an inspection is created. It takes the inspection date attribute from the related table and populates the feature class with that date.&amp;nbsp; The users wanted this so they could quickly look at the features' attributes and see when the last inspection was done. &amp;nbsp;I have this working.&lt;/P&gt;&lt;P&gt;The users now want to modify the feature’s schema to have a field “LastConditionRatingInspectDate” and another field called “LastMaintenanceActivityDate”.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The inspection form has a field “InspectionReason” which gets populated, via a dropdown, with either “Condition Rating” or “Maintenance Activity”.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Based on what the field editor selects in the “InspectionReason” field, I need to have the inspection date populate the “LastConditionRatingInspectDate” if they select “Condition Rating” or the “LastMaintenanceActivityDate” if they select “Maintenance Activity”.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I was thinking an If-then-else would work.&amp;nbsp; If they select “Condition Rating” then the “LastConditionRatingInspectDate” field gets populated with the inspection date, else the “LastMaintenanceActivityDate” would get populated with the inspection date.&lt;/P&gt;&lt;P&gt;Any help on how to make this work would be greatly appreciated!&lt;/P&gt;&lt;P&gt;I’m currently testing using a fgdb in Pro, however, this will be moved to Enterprise for use in web app and Field Maps.&lt;/P&gt;&lt;P&gt;ArcGIS Pro 2.8.8&lt;/P&gt;&lt;P&gt;Arc Enterprise 10.9.1&lt;/P&gt;&lt;P&gt;Here’s the functioning code:&lt;/P&gt;&lt;P&gt;var parent_id = $feature.ParentGUID&lt;/P&gt;&lt;P&gt;&amp;nbsp;if (IsEmpty(parent_id))&lt;/P&gt;&lt;P&gt;&amp;nbsp; return parent_id;&lt;/P&gt;&lt;P&gt;//On the next line, the field LastInspectionDate is the current field which would need to be changed to reflect the new field name&lt;/P&gt;&lt;P&gt;var parent_class = FeatureSetByName($datastore, "CTDOT_Planning_OtherDrainage", ["globalid", 'LastInspectionDate'], false);&lt;/P&gt;&lt;P&gt;var parent_records = Filter(parent_class, "globalid = @parent_id");&lt;/P&gt;&lt;P&gt;return {&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'edit': [{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'className': 'CTDOT_Planning_OtherDrainage',&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'updates': [{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'globalID': $feature.ParentGUID,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'attributes': {&lt;/P&gt;&lt;P&gt;//On the next line the, the field LastInspectionDate is the current field which would need to be changed to reflect the new field name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 'LastInspectionDate': $feature.InspectionDate&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }]&lt;/P&gt;&lt;P&gt;&amp;nbsp; }]&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 18:47:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269552#M772</guid>
      <dc:creator>EricGlover3</dc:creator>
      <dc:date>2023-03-20T18:47:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a date field in the feature class from the inspection date in the related table based on a condition</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269593#M773</link>
      <description>&lt;P&gt;To post 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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You have to make the field that gets updated dependent on the value in InspectionReason. You're correct, you can do this with in if/else. Here, I use When(), which is multiple if/elses chained together, so you can even add more inspection reasons later on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also removed the unused loading of the parent table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var update_field = When(
  $feature.InspectionReason == "Condition Rating", "LastConditionRatingInspectDate",
  $feature.InspectionReason == "Maintenance Activity", "LastMaintenanceActivityDate",
  null // some other inspection reason
)
var parent_id = $feature.ParentGUID
if (IsEmpty(parent_id) || IsEmpty(update_field)) { return parent_id }

var update = {"globalID": parent_id, "attributes": {}}
update.attributes[update_field] = $feature.InspectionDate

return {
  'edit': [{
    'className': 'CTDOT_Planning_OtherDrainage',
    'updates': [update]
  }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 19:21:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269593#M773</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-20T19:21:35Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a date field in the feature class from the inspection date in the related table based on a condition</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269946#M774</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;Thank you so much for your quick response! It worked perfectly. I'm migrating a number of layers from AGOL to our new Enterprise.&amp;nbsp; In doing so, I'm trying to automate a number of steps.&amp;nbsp; I've completed four, and now with your help I have the fifth one completed.&amp;nbsp; I have two more to do.&amp;nbsp; I'll try to figure them out on my own and if I'm unsuccessful, I'll post to the community.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, thank you so much!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Mar 2023 17:14:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269946#M774</guid>
      <dc:creator>EricGlover3</dc:creator>
      <dc:date>2023-03-21T17:14:16Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a date field in the feature class from the inspection date in the related table based on a condition</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1404660#M1376</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/489243"&gt;@EricGlover3&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;In your initial post, you stated that you already have an attribute rule working that populates a feature class field from a related table field when a related table record is created.&amp;nbsp; I'm interested in learning how to do this.&amp;nbsp;&amp;nbsp;Would you be able to share that code?&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 15:29:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1404660#M1376</guid>
      <dc:creator>ChristopherBowering</dc:creator>
      <dc:date>2024-04-02T15:29:09Z</dc:date>
    </item>
  </channel>
</rss>

