Select to view content in your preferred language

Attribute Rules - Edit with Updates works in one rule but not another.

766
1
Jump to solution
07-27-2023 07:35 AM
TanGnar
Occasional Contributor

I am testing two calculation attribute rules. They are almost exactly the same... the only difference is an if statement that evaluates at the beginning. Both are update triggers. In one rule, which uses $originalFeature and detects changes in geometry, it works as intended. In the second, which uses $originalFeature  and detects a change in an attribute, it does not work. The part that apparently does not work is the 'edit' with attribute updates to other features in the same feature class. 

After some debugging, I've found that what I'm passing to 'updates' is a correctly formatted dictionary. I can't find anything in the code that indicates why it would not work for this rule, but it works fine for the other. I've tried many ways to isolate the issue, but have come up empty. Commented code below. 

 

var new_parent_property_id = $feature.ParentPropertyID
var old_parent_property_id = $originalfeature.ParentPropertyID

//see if the parent property id has changed
if (new_parent_property_id != old_parent_property_id) {
    //Creates empty array and counter for iterating
    var updates = []
    var counter = 0
    var gid = $feature.GlobalId
    //use this filter statement to get all of the records with same parent prop id for the SUM. 
    var sumfs = Filter($featureset, "ParentPropertyID = @new_parent_property_id")
    var newacres = Sum(sumfs, "GIS_TractAcres")
 
    // use this filter statement to exclude the edited record, so that the 'updates' doesn't kick back a cyclical error. 
    var fs = Filter($featureset, "ParentPropertyID = @new_parent_property_id AND GlobalId <> @gid")

    // iterate records and make 'updates' dictionary
    for (var f in fs){
        updates[counter] = { 
            'globalID': f.GlobalId,
            'attributes':{
                'GIS_PropertyAcres': newacres,      
            } 
        }
        counter++ 
    }

    // return a 'result' for the edited record. use 'edit' to modify the attributes of the other features in the table with the same parent prop id.
    return {
        'result': {
            "attributes": {
                "GIS_PropertyAcres": newacres,
                "longtext":Text(updates)
            }
        },
        
        // ~~~ This is the part that is apparently not working in this rule. ~~~
        'edit': [{
            'className': 'Arcade_Rules_Test',
            'updates': updates
        }]
 }
} else {
    return "Parent Prop ID didn't change."
}

 

Using ArcGIS Pro 2.9.5 and a file geodatabase. 

0 Kudos
1 Solution

Accepted Solutions
TanGnar
Occasional Contributor

Alright, kind of a ridiculous realization here... turns out it has been working, but it wasn't showing the edits 'in real time' for the second rule. This led me to believe that it wasn't working, because the updates were being shown immediately with the first rule.

So if anyone is getting frustrated at a rule that should be working... sort your table after the edit, maybe it is working after all. Womp womp 🙂

View solution in original post

0 Kudos
1 Reply
TanGnar
Occasional Contributor

Alright, kind of a ridiculous realization here... turns out it has been working, but it wasn't showing the edits 'in real time' for the second rule. This led me to believe that it wasn't working, because the updates were being shown immediately with the first rule.

So if anyone is getting frustrated at a rule that should be working... sort your table after the edit, maybe it is working after all. Womp womp 🙂

0 Kudos