<?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: Attribute rule to change domain value based on date in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1157284#M53211</link>
    <description>&lt;P&gt;It sounds as if you want the field to update itself when the specified date is passed. That is not possible. An Attribute Rule only triggers when you actively do something to a feature (insert/update/delete), they are not checked continually.&lt;/P&gt;&lt;P&gt;What you &lt;EM&gt;can &lt;/EM&gt;do is create a Batch Attribute Rule. These are rules that don't trigger on insert/update/delete, but are evaluated when the user wants.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Batch rules need Editor Tracking, so enable that for your feature class.&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/editing/enable-or-disable-editor-tracking.htm" target="_blank" rel="noopener"&gt;Enable or disable editor tracking—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Create a new Batch Calculation Attribute Rule&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_2-1648129126758.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37229i989FF58EC122A361/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1648129126758.png" alt="JohannesLindner_2-1648129126758.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;This will add a new field "VALIDATIONSTATUS" to your table.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Use your script or the script below (slightly modified)&lt;/LI&gt;&lt;LI&gt;Evaluate the rule periodically&lt;UL&gt;&lt;LI&gt;Use the tool&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/tool-reference/data-management/evaluate-rules.htm" target="_blank" rel="noopener"&gt;Evaluate Rules (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Either do that manually or write a Python script and run that automatically every night&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var skedenr = $feature.IntegerField
var utstallningsdatum = $feature.DateField

if(skedenr == null || skedenr == 105) {
  return 105
}
if(utstallningsdatum == null) {
  return skedenr
}
var datum = DateDiff(utstallningsdatum, Today())
return IIF(datum &amp;lt;= 0, 105, skedenr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My test features before and after evaluating the rule (on 2022-03-24)&lt;/P&gt;&lt;TABLE border="1" width="50%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Before&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;After&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="30%" height="200px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1648128567268.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37227i2971BDDA7B45C3D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1648128567268.png" alt="JohannesLindner_0-1648128567268.png" /&gt;&lt;/span&gt;&lt;/TD&gt;&lt;TD width="30%" height="200px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1648128647131.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37228i632D0100700C1296/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1648128647131.png" alt="JohannesLindner_1-1648128647131.png" /&gt;&lt;/span&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The second row didn't get changed because there was no date supplied.&lt;/LI&gt;&lt;LI&gt;The last row didn't get changed because &lt;STRONG&gt;DateDiff(datevalue, Today())&lt;/STRONG&gt; returned 1 hour. Might be related to daylight saving time, I don't know. This is a file gdb, did not test on enterprise.&lt;UL&gt;&lt;LI&gt;To change this behavior, you can replace the last 2 lines with this:&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var datum = DateDiff(utstallningsdatum, Today(), "hours")
return IIF(datum &amp;lt;= 1, 105, skedenr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Mar 2022 14:05:50 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-03-24T14:05:50Z</dc:date>
    <item>
      <title>Attribute rule to change domain value based on date</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1156543#M53143</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;&lt;P&gt;I'm trying to create an attribute rule that changes a domain value when a specific date is passed.&lt;/P&gt;&lt;P&gt;So the main problem I'm trying to solve is this:&lt;BR /&gt;When a feature is created, the feature gets domain code 105. When the feature is up for review in a process, the administrator changes the domain code from 105 to a value between 100-104 and sets a end date in another field. When the end date is passed I want the domain code to change back to 105.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="PetronellaHauptmann1_0-1648024129484.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37068iD82517FF763EB952/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PetronellaHauptmann1_0-1648024129484.png" alt="PetronellaHauptmann1_0-1648024129484.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Here is the Arcade-code I've been working on. It validates just fine, but when I execute the rule the domain value does not change.&amp;nbsp;&lt;/P&gt;&lt;P&gt;var skedenr = $feature.Skede&lt;BR /&gt;var utstallningsdatum = $feature.Utstallningsdatum&lt;BR /&gt;var dagensdatum = Today()&lt;BR /&gt;var skede = IIF(skedenr != 105, '1', '3')&lt;BR /&gt;var datum = DateDiff(utstallningsdatum, dagensdatum)&lt;BR /&gt;var datums = IIF(datum &amp;lt;= 0, '1', '3')&lt;BR /&gt;var sant = IIF(skede + datums == 2, 105, skedenr)&lt;BR /&gt;return sant&lt;/P&gt;&lt;P&gt;Super grateful for help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 08:30:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1156543#M53143</guid>
      <dc:creator>PetronellaHauptmann1</dc:creator>
      <dc:date>2022-03-23T08:30:00Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change domain value based on date</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1157284#M53211</link>
      <description>&lt;P&gt;It sounds as if you want the field to update itself when the specified date is passed. That is not possible. An Attribute Rule only triggers when you actively do something to a feature (insert/update/delete), they are not checked continually.&lt;/P&gt;&lt;P&gt;What you &lt;EM&gt;can &lt;/EM&gt;do is create a Batch Attribute Rule. These are rules that don't trigger on insert/update/delete, but are evaluated when the user wants.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Batch rules need Editor Tracking, so enable that for your feature class.&lt;BR /&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/help/editing/enable-or-disable-editor-tracking.htm" target="_blank" rel="noopener"&gt;Enable or disable editor tracking—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Create a new Batch Calculation Attribute Rule&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_2-1648129126758.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37229i989FF58EC122A361/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_2-1648129126758.png" alt="JohannesLindner_2-1648129126758.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;UL&gt;&lt;LI&gt;This will add a new field "VALIDATIONSTATUS" to your table.&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;LI&gt;Use your script or the script below (slightly modified)&lt;/LI&gt;&lt;LI&gt;Evaluate the rule periodically&lt;UL&gt;&lt;LI&gt;Use the tool&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/tool-reference/data-management/evaluate-rules.htm" target="_blank" rel="noopener"&gt;Evaluate Rules (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Either do that manually or write a Python script and run that automatically every night&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var skedenr = $feature.IntegerField
var utstallningsdatum = $feature.DateField

if(skedenr == null || skedenr == 105) {
  return 105
}
if(utstallningsdatum == null) {
  return skedenr
}
var datum = DateDiff(utstallningsdatum, Today())
return IIF(datum &amp;lt;= 0, 105, skedenr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My test features before and after evaluating the rule (on 2022-03-24)&lt;/P&gt;&lt;TABLE border="1" width="50%"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="50%" height="24px"&gt;Before&lt;/TD&gt;&lt;TD width="50%" height="24px"&gt;After&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD width="30%" height="200px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1648128567268.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37227i2971BDDA7B45C3D9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1648128567268.png" alt="JohannesLindner_0-1648128567268.png" /&gt;&lt;/span&gt;&lt;/TD&gt;&lt;TD width="30%" height="200px"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1648128647131.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/37228i632D0100700C1296/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1648128647131.png" alt="JohannesLindner_1-1648128647131.png" /&gt;&lt;/span&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Notes:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The second row didn't get changed because there was no date supplied.&lt;/LI&gt;&lt;LI&gt;The last row didn't get changed because &lt;STRONG&gt;DateDiff(datevalue, Today())&lt;/STRONG&gt; returned 1 hour. Might be related to daylight saving time, I don't know. This is a file gdb, did not test on enterprise.&lt;UL&gt;&lt;LI&gt;To change this behavior, you can replace the last 2 lines with this:&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var datum = DateDiff(utstallningsdatum, Today(), "hours")
return IIF(datum &amp;lt;= 1, 105, skedenr)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Mar 2022 14:05:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1157284#M53211</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-03-24T14:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: Attribute rule to change domain value based on date</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1160673#M53570</link>
      <description>&lt;P&gt;It works just fine.&lt;/P&gt;&lt;P&gt;I am so grateful for your help!&lt;/P&gt;</description>
      <pubDate>Mon, 04 Apr 2022 08:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/attribute-rule-to-change-domain-value-based-on/m-p/1160673#M53570</guid>
      <dc:creator>PetronellaHauptmann1</dc:creator>
      <dc:date>2022-04-04T08:00:29Z</dc:date>
    </item>
  </channel>
</rss>

