Hi, I have a question unrelated to this post, but you were very helpful with my last Arcade question. I have two attribute rules that I need to combine, because they are firing in the wrong order as separate rules. I need to first calculate the GPM from a value entered into the Flow field (both are fields in the same related table). I need that GPM value to update a parent feature class in the "class" field. Do you have an idea how I could combine these two expressions?
//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
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
}
]
};