# In-place equations with undefined values being cast as zero

**URL:** <https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254>\
**Category:** Help\
**Created:** [November 19, 2018, 9:06pm UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254 "2018-11-19T21:06:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paul\_wareham](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@paul\_wareham](https://forums.losant.com/u/paul_wareham)\
**Post date:** [November 19, 2018, 9:06pm UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254/1 "2018-11-19T21:06:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [November 21, 2018, 10:29pm UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254/2 "2018-11-21T22:29:06Z")

</div>

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:

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

```

---

<div class="post-metadata">

**Author:** ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)\
**Post date:** [June 30, 2019, 1:45pm UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254/3 "2019-06-30T13:45:04Z")

</div>

> [@Brandon\_Cannaday](#):
>
> !== 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

---

<div class="post-metadata">

**Author:** ![Brandon\_Cannaday](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/brandon_cannaday/32/14_2.png) [@Brandon\_Cannaday](https://forums.losant.com/u/Brandon_Cannaday)\
**Post date:** [June 30, 2019, 7:14pm UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254/4 "2019-06-30T19:14:22Z")

</div>

The syntax is essentially the same:

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

```

---

<div class="post-metadata">

**Author:** ![Alexander\_Kondrov](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/alexander_kondrov/32/1392_2.png) [@Alexander\_Kondrov](https://forums.losant.com/u/Alexander_Kondrov)\
**Post date:** [July 1, 2019, 7:17am UTC](https://forums.losant.com/t/in-place-equations-with-undefined-values-being-cast-as-zero/1254/5 "2019-07-01T07:17:44Z")

</div>

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