Hello community,
Following the immediate calculation rule example for updating features in the same feature class (calculation rule update a record in the same feature class), 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.
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.
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.
I have used the code from the thread and only altered the feature class name and field name. Any clue would be appreciated.
Gets error if features are more than five. Tried to edit AAA to DDDD.
Error - if other features more than five
Works if features are less than six. Edited AAA to DDDD
Works - if other feature less than six
I have prepared the code as per below below based on the example in another question, but this code did not work as mentioned.
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 <> @gid");
var updates = [];
for (var f in other_features) {
Push(updates, { globalID: f.GlobalID, attributes: { NAME: new_value } });
}
return {
edit: [
{
className: "TableA",
updates: updates,
},
],
};