<?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 field in the feature class based on two conditions in the related inspection table. in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1275699#M803</link>
    <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;I took your revised script and tested it with my FGDB and everything worked fine.&amp;nbsp; I then tested it in our SDE staging Portal and configured the inspection table with Field Maps.&amp;nbsp; Everything worked perfectly! I demonstrated it to the units that I'm building this for, and they loved it.&amp;nbsp; I made sure to give you all of the credit that you so rightly deserve for this.&amp;nbsp; I want to personally thank you for all of your help and that I truly appreciate your effort and knowledge in this matter.&amp;nbsp; The cost savings and data integrity will be immense.&lt;/P&gt;&lt;P&gt;Thank you!!!!!!!!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 05 Apr 2023 12:22:33 GMT</pubDate>
    <dc:creator>EricGlover3</dc:creator>
    <dc:date>2023-04-05T12:22:33Z</dc:date>
    <item>
      <title>Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1273472#M783</link>
      <description>&lt;P&gt;Hi ESRI Community,&lt;/P&gt;&lt;P&gt;I have another attribute rule question I need to ask, since you were so helpful last time. I have a drainage network layer that consists of a feature class with a field that I want to have populated based on &lt;STRONG&gt;two&lt;/STRONG&gt; conditions in the related inspection table.&lt;/P&gt;&lt;P&gt;The inspection table 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;The inspection table also has a field “OtherDrainageRatable” which gets populated via a dropdown.&lt;/P&gt;&lt;P&gt;The feature class name is CTDOT_Planning_OtherDrainage and has a field named “ConditionRatingInspectionStatus”.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The logic would work like this:&lt;/P&gt;&lt;P&gt;If the “InspectionReason” = “Condition Rating” and the “OtherDrainageRatable” = “Yes” then the “ConditionRatingInspectionStatus” in the feature = “Inspection Completed”.&lt;/P&gt;&lt;P&gt;If the “InspectionReason” = “Condition Rating” and the “OtherDrainageRatable” &lt;STRONG&gt;is not “Yes”&lt;/STRONG&gt; then the “ConditionRatingInspectionStatus” in the feature = “Inspection Attempted”.&lt;/P&gt;&lt;P&gt;I was able to get the first part to work but I don’t know how to handle the else part of the second condition.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;Thank you in advance for any assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Mar 2023 12:25:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1273472#M783</guid>
      <dc:creator>EricGlover3</dc:creator>
      <dc:date>2023-03-30T12:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1273824#M784</link>
      <description>&lt;P&gt;So the things you need to know for this are the &lt;A href="https://developers.arcgis.com/arcade/guide/operators/#logical-operators" target="_blank" rel="noopener"&gt;logical operators in Arcade&lt;/A&gt;.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;==&amp;nbsp; &amp;nbsp; equal&lt;/LI&gt;&lt;LI&gt;!=&amp;nbsp; &amp;nbsp; &amp;nbsp;not equal,&lt;/LI&gt;&lt;LI&gt;&amp;lt;, &amp;lt;=, &amp;gt;, &amp;gt;=&amp;nbsp; &amp;nbsp; less than, less than or equal, greater than, greater than or equal&lt;/LI&gt;&lt;LI&gt;&amp;amp;&amp;amp;&amp;nbsp; &amp;nbsp;and&lt;/LI&gt;&lt;LI&gt;||&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;or&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;You can write your logic like this:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var rating_status = When(
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable == "Yes",
  "Inspection Completed",
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable != "Yes",
  "Inspection attemted",
  null  // default value, for example when InspectionReason is not "Condition Rating"
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And if we combine that with the rule from &lt;A href="https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-date-field/m-p/1269552" target="_blank" rel="noopener"&gt;your previous question:&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// abort if there is no ParnetGUID
var parent_id = $feature.ParentGUID
if (IsEmpty(parent_id)) { return parent_id }

// get the inspection status
var inspection_status= When(
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable == "Yes",
  "Inspection Completed",
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable != "Yes",
  "Inspection attemted",
  null  // default value, for example when InspectionReason is not "Condition Rating"
)

// get the date field that should be updated
var date_field = When(
  $feature.InspectionReason == "Condition Rating", "LastConditionRatingInspectDate",
  $feature.InspectionReason == "Maintenance Activity", "LastMaintenanceActivityDate",
  null // some other inspection reason
)

// construct the update instructions
var update = {"globalID": parent_id, "attributes": {}}
update.attributes[date_field] = $feature.InspectionDate
update.attributes["ConditionRatingInspectionStatus"] = inspection_status

return {
  'edit': [{
    'className': 'CTDOT_Planning_OtherDrainage',
    'updates': [update]
  }]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 30 Mar 2023 20:25:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1273824#M784</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-03-30T20:25:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1274643#M786</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;I want to thank you again for your help, the script you provided worked perfectly.&lt;/P&gt;&lt;P&gt;I tried to make a modification to it to incorporate the last automation process I need to do for this workflow.&amp;nbsp; I followed your workflow to try to get this step to work but I'm getting an error message.&amp;nbsp; I tried matching what you did for the date field.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is your script with the areas I'm trying to update noted in Bold comments. Again, any advice would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you again!&lt;/P&gt;&lt;P&gt;// abort if there is no ParnetGUID&lt;BR /&gt;var parent_id = $feature.ParentGUID&lt;BR /&gt;if (IsEmpty(parent_id)) { return parent_id }&lt;/P&gt;&lt;P&gt;// get the inspection status&lt;BR /&gt;var inspection_status= When(&lt;BR /&gt;$feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable == "Yes",&lt;BR /&gt;"Inspection Completed",&lt;BR /&gt;$feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable != "Yes",&lt;BR /&gt;"Inspection Attempted",&lt;BR /&gt;null // default value, for example when InspectionReason is not "Condition Rating"&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;// My change. Populate the MaintenanceActivityStatus field in the feature&amp;nbsp;with the attribute from the MaintenanceReason (dropdown) field in the inspection table, when it's&amp;nbsp;not null.&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;// When the field has no attrubute selected then nothing happens to the feature.&lt;/STRONG&gt;&lt;BR /&gt;var update_field = When(&lt;BR /&gt;$feature.MaintenanceReason != null, "MaintenanceActivityStatus",&lt;BR /&gt;null // some other inspection reason&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;// get the date field that should be updated&lt;BR /&gt;var date_field = When(&lt;BR /&gt;$feature.InspectionReason == "Condition Rating", "LastConditionRatingInspectDate",&lt;BR /&gt;$feature.InspectionReason == "Maintenance Activity", "LastMaintenanceActivityDate",&lt;BR /&gt;null // some other inspection reason&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;// construct the update instructions&lt;BR /&gt;var update = {"globalID": parent_id, "attributes": {}}&lt;BR /&gt;update.attributes[date_field] = $feature.InspectionDate&lt;BR /&gt;update.attributes["ConditionRatingInspectionStatus"] = inspection_status&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;//error in next line. Invalid expression, Error on line 36, String type expected.&lt;/STRONG&gt;&lt;BR /&gt;update.attributes[update_field] = $feature.MaintenanceReason&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;return {&lt;BR /&gt;'edit': [{&lt;BR /&gt;'className': 'CTDOT_Planning_OtherDrainage',&lt;BR /&gt;'updates': [update]&lt;BR /&gt;}]&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 03 Apr 2023 13:16:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1274643#M786</guid>
      <dc:creator>EricGlover3</dc:creator>
      <dc:date>2023-04-03T13:16:23Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1274928#M787</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN&gt;I tried matching what you did for the date field.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;What we did with the date field is not applicable here.&lt;/P&gt;&lt;P&gt;For the date field, we have to decide which one of two fields to update based on the inspection reason.&lt;/P&gt;&lt;P&gt;For this problem, you want to copy the value in MaintenanceReason over to parent.MaintenanceActivityStatus. If there is no such value, don't edit the parent field. You can do that with a simple if statement (and remove your update_field part):&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;if($feature.MaintenanceReason != null) {
    update.attributes["MaintenanceActivityStatus"] = $feature.MaintenanceReason
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;All together:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// abort if there is no ParnetGUID
var parent_id = $feature.ParentGUID
if (IsEmpty(parent_id)) { return parent_id }

// get the inspection status
var inspection_status= When(
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable == "Yes",
  "Inspection Completed",
  $feature.InspectionReason == "Condition Rating" &amp;amp;&amp;amp; $feature.OtherDrainageRatable != "Yes",
  "Inspection attemted",
  null  // default value, for example when InspectionReason is not "Condition Rating"
)

// get the date field that should be updated
var date_field = When(
  $feature.InspectionReason == "Condition Rating", "LastConditionRatingInspectDate",
  $feature.InspectionReason == "Maintenance Activity", "LastMaintenanceActivityDate",
  null // some other inspection reason
)

// construct the update instructions
var update = {"globalID": parent_id, "attributes": {}}
update.attributes[date_field] = $feature.InspectionDate
update.attributes["ConditionRatingInspectionStatus"] = inspection_status
if($feature.MaintenanceReason != null) {
    update.attributes["MaintenanceActivityStatus"] = $feature.MaintenanceReason
}

return {
  'edit': [{
    'className': 'CTDOT_Planning_OtherDrainage',
    'updates': [update]
  }]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 03 Apr 2023 19:34:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1274928#M787</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-04-03T19:34:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1275699#M803</link>
      <description>&lt;P&gt;Hi Johannes,&lt;/P&gt;&lt;P&gt;I took your revised script and tested it with my FGDB and everything worked fine.&amp;nbsp; I then tested it in our SDE staging Portal and configured the inspection table with Field Maps.&amp;nbsp; Everything worked perfectly! I demonstrated it to the units that I'm building this for, and they loved it.&amp;nbsp; I made sure to give you all of the credit that you so rightly deserve for this.&amp;nbsp; I want to personally thank you for all of your help and that I truly appreciate your effort and knowledge in this matter.&amp;nbsp; The cost savings and data integrity will be immense.&lt;/P&gt;&lt;P&gt;Thank you!!!!!!!!&lt;/P&gt;&lt;P&gt;Eric&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 12:22:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1275699#M803</guid>
      <dc:creator>EricGlover3</dc:creator>
      <dc:date>2023-04-05T12:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1275842#M804</link>
      <description>&lt;P&gt;Glad to have helped. Please select an answer as solution so that this question is shown as answered.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 15:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1275842#M804</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2023-04-05T15:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1294116#M936</link>
      <description>&lt;P&gt;I am curious how the first part of this question is achieved with arcade, i.e. the ability to reference the related record from the related table of the feature? I am trying to create an attribute rule on a feature class that populates a field on the feature class based on a value from its most recent related record. Can someone please point me in the correct direction?&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2023 16:16:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1294116#M936</guid>
      <dc:creator>Gene_Sipes</dc:creator>
      <dc:date>2023-05-30T16:16:20Z</dc:date>
    </item>
    <item>
      <title>Re: Create Attribute Rule that populates a field in the feature class based on two conditions in the related inspection table.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1382185#M1289</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt;&amp;nbsp;hi, this is an old post but I'm attempting a similar attribute rule expression for a project in Pro. This data was brought in from an .mdb and the relationships have already been established on a UID that is not a Global ID. To create an attribute rule to push a calculation of table entries to a cell in the feature class, I established a global id field for the new .fgdb feature classes. 1) Is it okay to leave the relationships as they are?&amp;nbsp; and 2) Do I need to add new GUID fields to the related tables? Thank you!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Feb 2024 14:28:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/create-attribute-rule-that-populates-a-field-in/m-p/1382185#M1289</guid>
      <dc:creator>KristalWalsh</dc:creator>
      <dc:date>2024-02-14T14:28:18Z</dc:date>
    </item>
  </channel>
</rss>

