# Vision Barcode Component behavior when no barcode?

**URL:** <https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [February 26, 2025, 5:35pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919 "2025-02-26T17:35:13Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![andonalerts](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@andonalerts](https://forum.inductiveautomation.com/u/andonalerts)\
**Post date:** [February 26, 2025, 5:35pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/1 "2025-02-26T17:35:13Z")

</div>

I have a Vision Barcode Component which displays data from a tag. Between parts, the tag is empty so the Barcode Component shows a red error which is ugly.

I'm using property change script to try to hide the ugly control:

```python
if event.propertyName == "code": # Ensure we only trigger on text changes
    barcode_value = event.source.code # Read the current barcode value
    if barcode_value is None or barcode_value == "" or barcode_value == "0":  
        event.source.visible = False
    else:
        event.source.visible = True

```

But something seems to be generating an exception:

12:26:37.682 [AWT-EventQueue-0] ERROR Vision.Barcode - Caught unexpected exception while recalculating barcode size for string 'null'  
java.lang.NullPointerException: null

It really seems like there should be a "hide if no data" checkbox on the Barcode Component. What is the proper way to use the Barcode Component 'between parts' when there is no barcode?

(edit: fixed formatting)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [February 26, 2025, 5:40pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/2 "2025-02-26T17:40:40Z")

</div>

Typically a null pointer exception (NPE) is a bug. Consider contacting [support](https://support.inductiveautomation.com) with a replication example. This forum is not official support.

Also, please properly format your code, it makes it easier for others to read and it maintains proper whitespace, which is important for jython. You can edit your post by clicking the pencil icon on the bottom right. [Wiki - how to post code on this forum](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [February 26, 2025, 5:42pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/3 "2025-02-26T17:42:25Z")

</div>

Consider moving the tag binding to a custom property, then using an expression binding involving `coalesce()` to replace the temporary null with an empty string, or some other string default.

(The NPE is still a bug worth reporting.)

---

<div class="post-metadata">

**Author:** ![andonalerts](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@andonalerts](https://forum.inductiveautomation.com/u/andonalerts)\
**Post date:** [February 26, 2025, 7:22pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/4 "2025-02-26T19:22:36Z")

</div>

> [@pturmel](#):
>
> Consider moving the tag binding to a custom property,

This seems like the correct solution that I should be using everywhere, but the Barcode Component does not seem to have Custom Properties if I am looking in the right place:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/a/0ab6bf79413faeacee0d74390a6cddab6fcb5e4b.png)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [February 26, 2025, 7:26pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/5 "2025-02-26T19:26:12Z")

</div>

Create a custom property on the root container instead.

---

<div class="post-metadata">

**Author:** ![andonalerts](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@andonalerts](https://forum.inductiveautomation.com/u/andonalerts)\
**Post date:** [March 5, 2025, 5:09pm UTC](https://forum.inductiveautomation.com/t/vision-barcode-component-behavior-when-no-barcode/102919/6 "2025-03-05T17:09:39Z")

</div>

> [@pturmel](#):
>
> coalesce

I created a Custom Property on the root container with an expression binding of coalesce({[default]Station30/Barcode}, "") and that fixed the exception.

I also reported the issue to Inductive support.

Thanks for your help and support!!!!

joe
