Computed Value in Trigger
How do you get a field value in a trigger if that field is computed? If I use getFieldDisplayString then nothing is returned. If I use getFieldValue then I get a null.
How do you get a field value in a trigger if that field is computed? If I use getFieldDisplayString then nothing is returned. If I use getFieldValue then I get a null.
Is your trigger in PRE mode?
It's been a couple months since I had to look into that but I'm pretty sure that in that case, your formula may be right but the computation isn't performed by Integrity yet. The only way you get the new calculated value it in POST mode. Of course, that's not helpful if you want to do something with it and save it somewhere. By the way, getFieldValue and get NewFieldValue don't make a difference here. They both display the old value, which in your case is probably not yet set and therefore null.
I've looked into all kinds of ways to cause another field to change and therefore trigger a caclulation after the fact, use the API in post mode, etc, but I usually end up with a secondary edit and something that's going to be incredibly difficult to maintain, or confuses the user (they get an edit conflict when there is no apparent reason).
If possible, it's better to do (or redo) whatever calculation the field does in your trigger and use the computed field for display only.
I agree with Joe, getting the calculation done when you call the field would be of great help, although I can see why it's probably technically challenging.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.