<?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: Problem - calculation works and does not work depending on number of features. in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336220#M1138</link>
    <description>Can you post your code so we can see what is going on.&lt;BR /&gt;</description>
    <pubDate>Mon, 09 Oct 2023 09:23:02 GMT</pubDate>
    <dc:creator>MikeMillerGIS</dc:creator>
    <dc:date>2023-10-09T09:23:02Z</dc:date>
    <item>
      <title>Calculation works and does not work depending on number of features.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336210#M1137</link>
      <description>&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;Following the immediate calculation rule example for updating features in the same feature class (&lt;A href="https://community.esri.com/t5/attribute-rules-questions/can-a-calculation-rule-update-a-record-in-the-same/m-p/1332608#M1133" target="_self"&gt;calculation rule update a record in the same feature class&lt;/A&gt;), I have come across a mysterious problem that results in two different scenarios, seems to be caused by the difference in the number of features that share the same attribute as the one being edited.&lt;/P&gt;&lt;P&gt;The rule will trigger an error if the number of records sharing the same attribute is greater than five. However, if the number of records sharing the same attribute is less than six, it works as configured.&lt;/P&gt;&lt;P&gt;For example, there are six records that have 'AAA' in the 'NAME' field in the table below. In this case, the calculation ends up with an error, displaying the message "evaluation of attribute rules is cyclic or exceeds the maximum cascading level." However, the calculation works as configured if the records with 'AAA' are less than six – please see the pictures below.&lt;/P&gt;&lt;P&gt;I have used the code from the thread and only altered the feature class name and field name. Any clue would be appreciated.&lt;/P&gt;&lt;P&gt;Gets error if features are more than five. Tried to edit AAA to DDDD.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Error - if other features more than five" style="width: 939px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82652i33FA9B3953541B74/image-size/large?v=v2&amp;amp;px=999" role="button" title="error_if_records_more_than_six.jpg" alt="Error - if other features more than five" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Error - if other features more than five&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Works if features are less than six. Edited AAA to DDDD&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Works - if other feature less than six" style="width: 890px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/82651iC4659520C5B9F8E1/image-size/large?v=v2&amp;amp;px=999" role="button" title="no_error_if_records_less_than_six.jpg" alt="Works - if other feature less than six" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Works - if other feature less than six&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Oct 2023 07:56:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336210#M1137</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-10-09T07:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem - calculation works and does not work depending on number of features.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336220#M1138</link>
      <description>Can you post your code so we can see what is going on.&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Oct 2023 09:23:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336220#M1138</guid>
      <dc:creator>MikeMillerGIS</dc:creator>
      <dc:date>2023-10-09T09:23:02Z</dc:date>
    </item>
    <item>
      <title>Re: Problem - calculation works and does not work depending on number of features.</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336222#M1139</link>
      <description>&lt;P&gt;I have prepared the code as per below below based on the example in another question, but this code did not work as mentioned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var old_value = $originalfeature.NAME;
var new_value = $feature.NAME;

if (new_value == old_value) {return}

var gid = $feature.GlobalID;
var other_features = Filter(FeaturesetByName($datastore, "TableA", ["*"]), "NAME = @old_value AND GlobalID &amp;lt;&amp;gt; @gid");

var updates = [];
for (var f in other_features) {
    Push(updates, { globalID: f.GlobalID, attributes: { NAME: new_value } });
}

return {
    edit: [
        {
            className: "TableA",
            updates: updates,
        },
    ],
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Oct 2023 07:00:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/calculation-works-and-does-not-work-depending-on/m-p/1336222#M1139</guid>
      <dc:creator>Aнастасия88</dc:creator>
      <dc:date>2023-10-10T07:00:28Z</dc:date>
    </item>
  </channel>
</rss>

