# isNull() always returning false

**URL:** <https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346>\
**Category:** Ignition\
**Created:** [April 12, 2022, 7:03am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346 "2022-04-12T07:03:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 12, 2022, 7:03am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/1 "2022-04-12T07:03:02Z")

</div>

I have created a UDT called MyUDT.  
The UDT has one parameter; a String called UDTParameter.  
The UDT has one tag; an expression tag called `IsParameterNull` with the expression `isNull({UDTParameter})`

I am expecting that when I create an instance of this UDT, if I do not define the parameter, my expression tag will be true. However, it is always false.

What am I missing here?

 ![Screen Shot 2022-04-12 at 4.59.19 pm](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e8933fe729b256b10d87b5b7bcb4dc3b9ae65b5e.jpeg)  
 ![Screen Shot 2022-04-12 at 4.59.28 pm](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/0/b046c9cd4c803eacab4ed338737d2416e987d2e5.jpeg)  
 ![Screen Shot 2022-04-12 at 4.59.45 pm](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d768d08b53e00f0bfca9589ba4cb39d6face72b.jpeg)  
 ![Screen Shot 2022-04-12 at 4.59.57 pm](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/0/50a4f34ad08a23a39f4b2a35d60c7fe306f17157.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 12, 2022, 7:50am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/2 "2022-04-12T07:50:02Z")

</div>

I’m having difficulty proving it but I suspect that since you have defined the parameter as a string that it is now an empty string and not a _null_.

Try `{UDTParameter}=""` or `if({UDTParameter}="", true, false)` in your expression instead.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [April 12, 2022, 8:29am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/3 "2022-04-12T08:29:35Z")

</div>

The isNull expression is only viable for a tag not for parameters.  
The best way to do should be to check like a @Transistor mention with a if expression.  
But i don't think that a null parameter is see as a empty string.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [April 12, 2022, 8:59am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/4 "2022-04-12T08:59:24Z")

</div>

> [@Arnaud\_Declerck](#):
>
> The isNull expression is only viable for a tag not for parameters.

That may not be quite correct. The manual says,

```auto
//Returns "Value is Null" if the property is null, and the value otherwise.
if` `(isNull({Root Container.MyProperty}), ` `"Value is Null"` `, {Root Container.MyProperty})

```

[https://docs.inductiveautomation.com/display/DOC81/isNull](https://docs.inductiveautomation.com/display/DOC81/isNull)

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [April 12, 2022, 11:40am UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/5 "2022-04-12T11:40:06Z")

</div>

This if for a property in a container not a udt parameter.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 12, 2022, 10:24pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/6 "2022-04-12T22:24:47Z")

</div>

It’s definitely null and not an empty string. The way I first discovered this was that I have a UDT which has three parameters:

```auto
Device Name
PLC Tag
PID Tag

```

I use Device Name and PLC Tag to build the OPC path, and PID tag is just the PID tag of the device for documentation purposes, e.g. TT1001.

Then, I have an expression tag in the UDT called `PIDTag`. The expression was originally:

```auto
if({PID Tag} = "", {PLC Tag}, {PID Tag})

```

…basically, if a PID tag is specified when the instance is created, use the specified PID tag. If no PID tag is specified, use the PLC tag as the PID tag, because 99% of the time, the PLC tag will actually _be_ the PID tag, so I can save 7 seconds of typing by making that the default assumption.

But, it didn’t work, because the PID Tag parameter was not “” (i.e. blank), it was null. So, I changed my expression:

```auto
if({PID Tag} = "" || isNull({PID Tag}), {PLC Tag}, {PID Tag})

```

…but it still doesn’t work, and I’ve established that it’s because isNull is always returning false.

So my parameter is not “” (blank), and `isNull()` refuses to acknowledge that it’s null, and I’m stuck.

My workaround is to go into all my UDT definitions, and in each parameter, insert a blank space, then come back and delete it. Now my parameters _are_ “” (blank) and no longer null, so my original expression works. But it’s a hacky workaround and I _hate_ not knowing why it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 12, 2022, 10:38pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/7 "2022-04-12T22:38:17Z")

</div>

I’m going to open a bug ticket for this… it’s very easy to mock up with the information in your original post.

What the `isNull` expression sees, for some reason, is a String value of `"{ParamName}"` instead of `null`. (with whatever your actual param name is)

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 12, 2022, 10:50pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/8 "2022-04-12T22:50:11Z")

</div>

Thanks, glad it’s not just me! Is there a way to track the status of the ticket so that I can see when it gets fixed?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 12, 2022, 10:52pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/9 "2022-04-12T22:52:08Z")

</div>

This post is linked in the issue, so somebody _should_ come back and update it… but the best/official way would be to open a ticket with support instead. They are supposed to notify customers when an associated issue is closed…

You can probably save some time by referencing this forum post and IGN-5870.

---

<div class="post-metadata">

**Author:** ![ASF](https://avatars.discourse-cdn.com/v4/letter/a/c4cdca/32.png) [@ASF](https://forum.inductiveautomation.com/u/ASF)\
**Post date:** [April 12, 2022, 11:00pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/10 "2022-04-12T23:00:50Z")

</div>

Thanks, will do!

---

<div class="post-metadata">

**Author:** ![Alex\_Nelson](https://avatars.discourse-cdn.com/v4/letter/a/e47774/32.png) [@Alex\_Nelson](https://forum.inductiveautomation.com/u/Alex_Nelson)\
**Post date:** [August 8, 2023, 4:58pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/11 "2023-08-08T16:58:04Z")

</div>

Following up on this, this issue has been fixed and will be available in tonights nightly build:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/b/7bb49f5712818d924916eeb8e989777c635cf1c7.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [August 8, 2023, 5:05pm UTC](https://forum.inductiveautomation.com/t/isnull-always-returning-false/58346/12 "2023-08-08T17:05:48Z")

</div>

> This is the first time Alex\_Nelson has posted — let’s welcome them to our community!

Welcome to the community, @Alex_Nelson. (As instructed.)
