I currently have two Arcade expressions as attribute rules that I need to combine into one because they evaluate in the wrong order, but I can't figure out how to combine them. I need GPM calculated from a value entered in the Flow field in a related table, and I need the Class field updated in the parent class by this value. Using ArcGIS Pro 3.1.0.
Could anyone help me figure out how to combine these, and which field should I choose in the dropdown?
These currently have GPM and hydrantObjid fields selected as these rules are on the related table.
//Calculate GPM
var flow = $feature["Flow"];
var gpm = 0;
if (!isEmpty(flow)) {
gpm = (29.7 * (2.5 * 2.5) * Sqrt(flow) * 0.9)
}
return gpm;
//Update parent class based on GPM value
var parent_id = $feature.hydrantObjid ;
var parent_class = FeatureSetByName($datastore, "hydrantCopy", ["OBJECTID", 'class'], false);
var parent_records = Filter(parent_class, "OBJECTID = @parent_id");
var updates = [];
var i = 0;
var new_value = 'no gpm';
if ($feature.GPM >= 1500) {
new_value = "Blue - 1500 GPM or Greater";
}
else if ($feature.GPM >= 1000) {
new_value = "Green - 1000-1499 GPM";
}
else if ($feature.GPM >= 500){
new_value = "Orange - 500-999 GPM";
}
else {
new_value = "Red - 0-499 GPM";
}
for (var row in parent_records) {
// If the parent row is null or has a different value, updated it
if (IsEmpty(row['class']) || row['class'] != new_value)
{
updates[i++] = {
'OBJECTID': parent_id,
'attributes': {"class": new_value}
};
}
}
return {
'result': parent_id,
'edit': [
{'className': 'hydrantCopy',
'updates': updates
}
]
};