Erratic Behavior with Ternary Operator in "Only Run When" Condition Evaluating a Form's .initialData and .data

I'm trying to trigger an email notification when a user-input percentage value crosses the 80% threshold. It should only trigger when the value crosses 80%, as this form will be resubmitted multiple times until a project gets to 100%, but we only want notification on that 80% cross.

I'm trying to get to this information via the form's .initialData versus .data parameters.

I've got the email script setup as a trigger event handler on a successful form submit. This trigger is limited by an "only run when" condition, which is the part I'm trying to figure out.

Current "only run when" script:
(if initialData is less than 80% AND if new data is greater than or equal to 80%, true)

{{ 
  operationsReviewForm.initialData.Opertions_PctWorkComplete.valueOf() < 0.80
  && 
  operationsReviewForm.data.Opertions_PctWorkComplete.valueOf() >= 0.80
  ? true : false
}}

I've tried various combinations of parentheses to no avail. Tried with/without the .valueOf().

Each individual condition (without the &&) evaluates erratically, sometimes true, sometimes false - which makes me wonder if it's even possible to evaluate this .initialData and .data properly.

This shows the email script code and output from some successful emails without the &&.

State of my form showing the numerical differences before a Submit:
image

image

So it seems like the data is all there and outputting to the email, but I can't get the greater thans or && to evaluate properly. Any ideas?

remove the "? true : false", it should work

Still doesn't operate logically. with .valueOf() it'll trigger an email on all instances. When I drop the .valueOf() it doesn't trigger any emails.

I added test fields in the email and with/without .valueOf() seem to deliver the same value.

In the event handler, it's saying these are empty strings, even though they parse through to the email as values.


if you could send screenshots of your form and your submit button with the event handlers

1 Like

Another note is that it looks like the form screenshot has Operations_PctWorkComplete spelled differently than in this screenshot:

Maybe that is why it is saying it's null?

That's it. Human error for the win.

2 Likes