In-place equations with undefined values being cast as zero

I have noticed that when an undefined value from a workflow gets transformed by a formula helper, then that value gets cast as 0 in the equation. For example, if engineTemperature is undefined, then {{add (multiply 1.8 data.body.data.message.dataReport.engineTemperature.value) 32}} calculates to 32 as though it were a valid measurement.

Is there a workaround for that?

You could add a Conditional Node that checks for the existence of the value before using it. The condition would look something like the following:

{{ data.body.data.message.dataReport.engineTemperature.value }} !== undefined

Hi Brandon,
Is there a way to check an undefined value inside of the Function Node with javascript? I.E. without placing an additional Conditional Node before it? If yes, I would appreciate if you provide a sample expression

The syntax is essentially the same:

if(payload.data.myField !== undefined) {
  // The variable exists
}
1 Like

Brandon, Thank you for the prompt reply. I used Try/Catch for now. It worked well. I will test your suggestion as well