Select to view content in your preferred language

Attribute Calculation Rule Exception

160
1
a month ago
Labels (2)
WillPlatt
Regular Contributor

I have created an Attribute Calculation Rule to calculate the depth a pole is put into the ground.  The rule is pole_height*0.1+3 (10% of the height of the pole plus 3 feet).  It works!! However, there are some exceptions to this rule and we need to be able to manual enter a value into this field.  During the rule creation I made sure that "Editable" was checked.  But, when I try to manual enter a value in the pole_depth field it just automatically recalculates based on the rule.

Is there a way to make exceptions for the rule?

Thanks for the help!

0 Kudos
1 Reply
DavidSolari
MVP Regular Contributor

You can try checking if the original value is different from the current value first:

if ($originalfeature.pole_depth == $feature.pole_depth) {
    return $feature.pole_height * 0.1 + 3
}

If you edited the field directly then the original value will be different from the current value and you don't return a new value, if you edited another field then the value should stay the same and then you can recalculate it.

That said, adjusting the height will probably re-run the rule again. Other solutions include running the rule on insert only, or adding a "is_calculated" field that is set when the rule is run, then checked to ensure it isn't run again.

0 Kudos