I have an attribute rule that runs on a field within a point feature class. The value of said field is passed to a desired related table field when said parent field is populated or updated. There is a 1:M relationship class using the GlobalID of the feature class and GUID of the table. As it stands, only the FIRST table record receives the updated value if there are multiple records associated with a single feature. This is due to the Arcade code using the 'First' FeatureSet function. I borrowed and adjusted this code to get me this far but I don't know how to further adjust it so ALL related records receive the same update from the parent field. Any help would be great!
if($originalfeature.Size == $feature.Size) { return }
var TEST = First(FeatureSetByRelationshipName($feature, "OCGIS.DPW_TESTING_REL"))
if(TEST == null) { return }
return {
"edit": [
{
"className": "OCGIS.DPW_TESTING_Table",
"updates": [
{"globalID": TEST.globalid, "attributes": {"Size": $feature.Size}}
]
}
]
}
Solved! Go to Solution.
Just need to loop over the FeatureSet and build a list of return values
if ($originalfeature.Size == $feature.Size) {
return
}
var fs = FeatureSetByRelationshipName($feature, "OCGIS.DPW_TESTING_REL");
var updates = [];
for (var feat in fs) {
Push(updates, {
"globalID": feat.globalid,
"attributes": {
"Size": $feature.Size
}
});
}
return {
"edit": [
{
"className": "OCGIS.DPW_TESTING_Table",
"updates": updates
}
]
}
Just need to loop over the FeatureSet and build a list of return values
if ($originalfeature.Size == $feature.Size) {
return
}
var fs = FeatureSetByRelationshipName($feature, "OCGIS.DPW_TESTING_REL");
var updates = [];
for (var feat in fs) {
Push(updates, {
"globalID": feat.globalid,
"attributes": {
"Size": $feature.Size
}
});
}
return {
"edit": [
{
"className": "OCGIS.DPW_TESTING_Table",
"updates": updates
}
]
}
Hi there @MikeMillerGIS . That did the trick! THANK YOU!
Hi again @MikeMillerGIS . I am running into an infinite loop issue ("the evaluation of attribute rules is cyclic or exceeds maximum cascading level.") when using the above rule in conjunction with another rule you helped me out with.
If I disable the rule which carries over children values to parent fields (set on child table), this initial update all related records rule (set on parent fc) works fine. When they're both enabled though, the initial rule throws the error when I update the parent field.
Note: The two rules do not deal with any of the same fields.
Do you know how the rule within this thread could be adjusted to prevent the looping/error situation?
Thanks!
From what I've been reading (and trying to understand..) this isn't too unusual of a problem. It doesn't stem from the dataset. I've seen it corrected by changing up the attribute rule script: Something like this example.
However, the examples of it being corrected are more complicated than mine so I'm not exactly sure how to apply a fix to my situation. The key part for me is the understanding of it which hurts my head sometimes!