<?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: Error &amp;quot;rules is cyclic or exceeds maximum cascading level&amp;quot; in Attribute Rules Questions</title>
    <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1232587#M660</link>
    <description>&lt;P&gt;No, it's not the point. I can return the result without do the Count(Features) before. My first example is working but the second example is not. So it's not a problem of the returning object.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 05:42:57 GMT</pubDate>
    <dc:creator>Zoggo</dc:creator>
    <dc:date>2022-11-17T05:42:57Z</dc:date>
    <item>
      <title>Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1231683#M658</link>
      <description>&lt;P&gt;I'm using a Attribute Calculation&amp;nbsp; Rule in ArcGIS Pro 3.0.2. It's a line featureclass in a fgdb. I checked "Exclude from application evaluation and triggered Insert und Update. The following very simple code is working when I alter the geometry:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;var feature_ = $feature; 
return {
    "edit": [{
        "className": "HydroEdgePro",
        "updates": [{
            "objectID": feature_["OBJECTID"],
            "attributes": {
                "BEMERKUNG": "test 2"
            }
        }]
    }, {
        "className": "arcade_log",
        "adds": [{
            "attributes": {
                "Value": "test"
            }
        }]
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I try to do something with the $FeatureSet (see example below) then I always get the Error "The evaluation of attribute rules is cyclic or exceeds maximum cascading level.":&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var feature_ = $feature;

var features = $FeatureSet;
var test = Count(features); 

return {
    "edit": [{
        "className": "HydroEdgePro",
        "updates": [{
            "objectID": feature_["OBJECTID"],
            "attributes": {
                "BEMERKUNG": "test 2"
            }
        }]
    }, {
        "className": "arcade_log",
        "adds": [{
            "attributes": {
                "Value": "test"
            }
        }]
    }]
}
&lt;/LI-CODE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Zoggo_0-1668518768943.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/55974i8B1534DED43EB923/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Zoggo_0-1668518768943.png" alt="Zoggo_0-1668518768943.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I don't understand why this happens. During debug mode the code is working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 13:26:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1231683#M658</guid>
      <dc:creator>Zoggo</dc:creator>
      <dc:date>2022-11-15T13:26:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1231778#M659</link>
      <description>&lt;P&gt;It seems that the feature triggers a rule that updates itself that triggers, which then retriggers the same attribute rule leading to an infinite loop and thus this error.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to update attributes in the same feature you can use the result keyword instead of updates.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;return {
    "result": {
        "attributes": {
                "BEMERKUNG": "test 2" //this update goes to the $feature
            }
     },
    "edit": [ {
        "className": "arcade_log",
        "adds": [{
            "attributes": {
                "Value": "test"
            }
        }]
    }]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2022 16:06:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1231778#M659</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2022-11-15T16:06:02Z</dc:date>
    </item>
    <item>
      <title>Re: Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1232587#M660</link>
      <description>&lt;P&gt;No, it's not the point. I can return the result without do the Count(Features) before. My first example is working but the second example is not. So it's not a problem of the returning object.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 05:42:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1232587#M660</guid>
      <dc:creator>Zoggo</dc:creator>
      <dc:date>2022-11-17T05:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1232789#M662</link>
      <description>&lt;P&gt;When you create a feature in the geodatabase it goes into a memory buffer for performance reasons. Additional updates to the feature by its object id will go to the buffer and then finally flushed at one swoop to the database.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what happened in your first rule, you created the feature, then asked AR to update the same feature field&amp;nbsp;BEMERKUNG to "Test 2". The AR found that the feature is still in memory and updated the field in memory then flushed it to the database. So the database only saw one insert.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However we can't always do this optimization. This optimization is not performed when a query against the class happens, because the query must see the feature being created (basic database semantics), so when a query happens to the class (that is your second rule where you did a count of the class), we had to flush the inserted feature to the database. Then the AR says wait a minute, we need to update the same feature (that is your return dictionary with objectId), that update actually becomes a physical second update which triggers the attribute rule again, and we go into the infinite cycle.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as a better practice, the attribute rule need to be written in a predictable way, if you want to updates fields in the same feature use the return "result" dictionary, with this we have knowledge in the AR to update the same row.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that clarifies it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 16:52:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1232789#M662</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2022-11-17T16:52:37Z</dc:date>
    </item>
    <item>
      <title>Re: Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1233678#M664</link>
      <description>&lt;P&gt;Thanks for your explanation. So it's not possible to write in another feature from the same datasource as the $feature like this?&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var dangleDistance = 1000;
var feature_ = $feature;

var features = $FeatureSet;
var test = Count(features);
console(test)   
   


return {
    "result" : {
            "attributes": {
                "BEMERKUNG": "test 23"
            }
    },
    "edit": [{
                "className": "HydroEdgePro",
                "updates": [{
                    "objectID": 3833,
                    "attributes": {
                           "BEMERKUNG" : "Bem 3833"
                     }
                }]
            },{
        "className": "arcade_log",
        "adds": [{
            "attributes": {
                "Value": "test"
            }
        }]
    }]
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where "HydroEdge" is the same FeatureClass as $Feature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Nov 2022 09:35:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1233678#M664</guid>
      <dc:creator>Zoggo</dc:creator>
      <dc:date>2022-11-21T09:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Error "rules is cyclic or exceeds maximum cascading level"</title>
      <link>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1233820#M665</link>
      <description>&lt;P&gt;&amp;nbsp;You need to have an exit condition, Attribute rules in this case is no different than recursive function.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you are updating object 3833, with value "Bem 3833", you might want to do a check first before doing the update. If the value is good exit the script else continue&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;var dangleDistance = 1000;
var feature_ = $feature;
//query objectid 3833
var fs1 = Filter($featureset, "objectid = 3833 AND BEMERKUNG = 'Bem 3833'");
var f = First(fs1);
//if is null, means feature 3833 doesn't have the value Bem 3833.. contiue to update. 
//if is NOT null, it means the value already there, just exist
if (f != null) 
    return; //quit the script

//else update the feature
return {
    "result" : {
            "attributes": {
                "BEMERKUNG": "test 23"
            }
    },
    "edit": [{
                "className": "HydroEdgePro",
                "updates": [{
                    "objectID": 3833,
                    "attributes": {
                           "BEMERKUNG" : "Bem 3833"
                     }
                }]
            },{
        "className": "arcade_log",
        "adds": [{
            "attributes": {
                "Value": "test"
            }
        }]
    }]
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 21 Nov 2022 16:47:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/attribute-rules-questions/error-quot-rules-is-cyclic-or-exceeds-maximum/m-p/1233820#M665</guid>
      <dc:creator>HusseinNasser2</dc:creator>
      <dc:date>2022-11-21T16:47:40Z</dc:date>
    </item>
  </channel>
</rss>

