# Expression with getBit() on UDT Custom Property

**URL:** <https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520>\
**Category:** Ignition\
**Created:** [May 24, 2012, 2:16pm UTC](https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520 "2012-05-24T14:16:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [May 24, 2012, 2:16pm UTC](https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520/1 "2012-05-24T14:16:55Z")

</div>

Using the getBit() function on a member of a UDT custom property throws errors in the Designer for: “Cannot call getBit() with a null value.” This happens on both windows and templates, and they pop up every time anything is done to the window or template.

In my case, I need to display a number of bit states out of some VFD Control and Status words, so a stack of error boxes appear frequently. At run-time, this appears to resolve, but not without numerous errors in the Java Console.

v7.4.2

Thanks.

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [May 24, 2012, 3:25pm UTC](https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520/2 "2012-05-24T15:25:23Z")

</div>

Since the template is tied to a UDT the values may be NULL initially. So just modify your expression to failover to a different value if NULL:`try(getBit({Template.UDT::IntegerValue}, 0), 0)`The try function will return 0 if the value is NULL or something is wrong.

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [May 24, 2012, 4:26pm UTC](https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520/3 "2012-05-24T16:26:20Z")

</div>

Thanks, Travis.

While this works much better, it does seem that, longer-term, the UDT’s and Templates beg to deal more gracefully with the null value issues they present during both design time and start-up (for both expressions and scripting).

Don’t get me wrong, however, the UDT’s and Templates have been a godsend on the project I’m working on.

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![pphillips](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@pphillips](https://forum.inductiveautomation.com/u/pphillips)\
**Post date:** [May 24, 2012, 5:14pm UTC](https://forum.inductiveautomation.com/t/expression-with-getbit-on-udt-custom-property/4520/4 "2012-05-24T17:14:04Z")

</div>

OK, just learned something that I probably should have figured out before, but the major part of this problem was caused by not having a tag binding to the UDT custom property at design time. Even if a different UDT custom property binding is passed via a parameter upon opening, the window opens better (no errors in the Java Console) if it the window is saved with an initial UDT binding.
