<?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 attribute rule fire twice in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275139#M795</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a probleme in my attribute rule that is executed twice in my feature service&lt;/P&gt;&lt;P&gt;the code calculate an id that increment by +1&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// get the feature with the highest id 
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);

var s= filter(m, "code_urb like 'URB%'")
var max_feature = First(OrderBy(s, "code_urb DESC")) 
// get the number of that id 
var max_number = 0 
if(max_feature != null) { // no features in featureset? -&amp;gt; this block is skipped and max_number is 0
  var txt = Replace(max_feature.code_urb, "URB", "") 
  max_number = Number(txt) 
} 
// calculate and return the new id 
return "URB" + Text(max_number + 1, "00000")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when i create record in arcgis pro through geodatabase evrything work perfectly, for each record i create the ID increment by +1, but when i edit the data through&amp;nbsp; feature service in Arcgis Pro or with the Edit widget in web app builder its like the attribute rule is executing twice (URB00002, URB00004, URB00006....) +2 for each new record.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture 2.PNG" style="width: 111px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67168i86B7886F4BAB4AED/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture 2.PNG" alt="Capture 2.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks for you help&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2023 09:34:02 GMT</pubDate>
    <dc:creator>solidsnake</dc:creator>
    <dc:date>2023-04-04T09:34:02Z</dc:date>
    <item>
      <title>attribute rule fire twice</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275139#M795</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;i have a probleme in my attribute rule that is executed twice in my feature service&lt;/P&gt;&lt;P&gt;the code calculate an id that increment by +1&lt;/P&gt;&lt;LI-CODE lang="c"&gt;// get the feature with the highest id 
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);

var s= filter(m, "code_urb like 'URB%'")
var max_feature = First(OrderBy(s, "code_urb DESC")) 
// get the number of that id 
var max_number = 0 
if(max_feature != null) { // no features in featureset? -&amp;gt; this block is skipped and max_number is 0
  var txt = Replace(max_feature.code_urb, "URB", "") 
  max_number = Number(txt) 
} 
// calculate and return the new id 
return "URB" + Text(max_number + 1, "00000")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;when i create record in arcgis pro through geodatabase evrything work perfectly, for each record i create the ID increment by +1, but when i edit the data through&amp;nbsp; feature service in Arcgis Pro or with the Edit widget in web app builder its like the attribute rule is executing twice (URB00002, URB00004, URB00006....) +2 for each new record.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture 2.PNG" style="width: 111px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/67168i86B7886F4BAB4AED/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture 2.PNG" alt="Capture 2.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;thanks for you help&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 09:34:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275139#M795</guid>
      <dc:creator>solidsnake</dc:creator>
      <dc:date>2023-04-04T09:34:02Z</dc:date>
    </item>
    <item>
      <title>Re: attribute rule fire twice</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275156#M796</link>
      <description>&lt;P&gt;You need to check Exclude from&amp;nbsp;&lt;SPAN&gt;exclude_from_client_evaluation.&amp;nbsp; If you do not check this, the client, such as ArcGIS Pro, will run the rule and when the data is sent to the database, it will run the rule again.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-attribute-rule.htm#GUID-D015A677-6AE2-4F70-9034-6E499F59430A" target="_blank" rel="noopener"&gt;https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-attribute-rule.htm#GUID-D015A677-6AE2-4F70-9034-6E499F59430A&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 10:54:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275156#M796</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-04-04T10:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: attribute rule fire twice</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275314#M797</link>
      <description>&lt;P&gt;I see that you already implemented the change requested by Mike but still get the same behavior as you illustrated on another &lt;A href="https://community.esri.com/t5/attribute-rules-blog/attribute-rules-exclude-from-application/bc-p/1275135/highlight/true#M24" target="_self"&gt;post&lt;/A&gt;. My guess since you are using 10.7.1 it could be a bug that we fixed in the next releases.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try the following script as a workaround&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// get the feature with the highest id 
var m = FeatureSetByName($datastore,'oncf.dgf.urb_projet', ['*']);
//remove $feature from the equation.
var oid = $feature.objectid
var s= filter(m, "code_urb like 'URB%' AND objectid &amp;lt;&amp;gt; " + oid)

var max_feature = First(OrderBy(s, "code_urb DESC")) 
// get the number of that id 
var max_number = 0 
if(max_feature != null) { // no features in featureset? -&amp;gt; this block is skipped and max_number is 0
  var txt = Replace(max_feature.code_urb, "URB", "") 
  max_number = Number(txt) 
} 
// calculate and return the new id 
return "URB" + Text(max_number + 1, "00000")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ound&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 15:17:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1275314#M797</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2023-04-04T15:17:03Z</dc:date>
    </item>
    <item>
      <title>Re: attribute rule fire twice</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1276015#M805</link>
      <description>&lt;P&gt;the modification in the arcade code you made worked perfectly.&lt;/P&gt;&lt;P&gt;we will update soon to Enterprise 10.9.1, i hope il will fixe the problem.&lt;/P&gt;&lt;P&gt;thanks you very much&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 22:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/attribute-rule-fire-twice/m-p/1276015#M805</guid>
      <dc:creator>solidsnake</dc:creator>
      <dc:date>2023-04-05T22:02:44Z</dc:date>
    </item>
  </channel>
</rss>

