<?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 Arcade Constraint Rule: Update a date field with Today() if any field except fieldA and fieldB are modified in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-constraint-rule-update-a-date-field-with/m-p/1481247#M83981</link>
    <description>&lt;P&gt;I am trying to create an attribute constraint rule that will populate a date field with current date if any of the fields of a feature class are updated except if the field is either fieldX and fieldY&lt;/P&gt;&lt;P&gt;The following Arcade works such that if any field is modified the modified_date field is updated even if there are modifications to fieldX or fieldY. So therefore it does not seem to me that the script is honoring the conditional statement with the array of columns to exclude.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Define the columns to exclude&lt;/P&gt;&lt;P&gt;var excludeColumns = ["fieldX", "fieldY"];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Initialize a flag to track if any relevant field is modified&lt;/P&gt;&lt;P&gt;var isModified = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Loop through each field in the feature&lt;/P&gt;&lt;P&gt;for (var field in $feature) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Check if the field is not in the exclude list&lt;/P&gt;&lt;P&gt;if (indexOf(excludeColumns, field) == -1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Check if the field has been modified&lt;/P&gt;&lt;P&gt;if (IsEmpty($originalFeature[field]) || $feature[field] != $originalFeature[field]) { isModified = true; break;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// If any relevant field is modified, update the "last_update" column with the current date&lt;/P&gt;&lt;P&gt;if (isModified) {&lt;/P&gt;&lt;P&gt;return { "result": Now()&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// If no relevant field is modified, return null to indicate no change&lt;/P&gt;&lt;P&gt;return {&lt;/P&gt;&lt;P&gt;"result": $feature["last_update"]&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;</description>
    <pubDate>Thu, 30 May 2024 15:46:12 GMT</pubDate>
    <dc:creator>WilliamZoeller1</dc:creator>
    <dc:date>2024-05-30T15:46:12Z</dc:date>
    <item>
      <title>Arcade Constraint Rule: Update a date field with Today() if any field except fieldA and fieldB are modified</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcade-constraint-rule-update-a-date-field-with/m-p/1481247#M83981</link>
      <description>&lt;P&gt;I am trying to create an attribute constraint rule that will populate a date field with current date if any of the fields of a feature class are updated except if the field is either fieldX and fieldY&lt;/P&gt;&lt;P&gt;The following Arcade works such that if any field is modified the modified_date field is updated even if there are modifications to fieldX or fieldY. So therefore it does not seem to me that the script is honoring the conditional statement with the array of columns to exclude.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Define the columns to exclude&lt;/P&gt;&lt;P&gt;var excludeColumns = ["fieldX", "fieldY"];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Initialize a flag to track if any relevant field is modified&lt;/P&gt;&lt;P&gt;var isModified = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Loop through each field in the feature&lt;/P&gt;&lt;P&gt;for (var field in $feature) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Check if the field is not in the exclude list&lt;/P&gt;&lt;P&gt;if (indexOf(excludeColumns, field) == -1) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// Check if the field has been modified&lt;/P&gt;&lt;P&gt;if (IsEmpty($originalFeature[field]) || $feature[field] != $originalFeature[field]) { isModified = true; break;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// If any relevant field is modified, update the "last_update" column with the current date&lt;/P&gt;&lt;P&gt;if (isModified) {&lt;/P&gt;&lt;P&gt;return { "result": Now()&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;// If no relevant field is modified, return null to indicate no change&lt;/P&gt;&lt;P&gt;return {&lt;/P&gt;&lt;P&gt;"result": $feature["last_update"]&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;</description>
      <pubDate>Thu, 30 May 2024 15:46:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcade-constraint-rule-update-a-date-field-with/m-p/1481247#M83981</guid>
      <dc:creator>WilliamZoeller1</dc:creator>
      <dc:date>2024-05-30T15:46:12Z</dc:date>
    </item>
  </channel>
</rss>

