# Disabled Tag in Expression Causes Error

**URL:** <https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [October 19, 2023, 4:02pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704 "2023-10-19T16:02:34Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 4:02pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/1 "2023-10-19T16:02:34Z")

</div>

I have a tag used in an expression inside a UDT. Sometimes the tag isn't needed, so it's disabled. Of course, now the expression throws an error because the first argument is null. Shouldn't the disabled tag be ignored (i.e. false)?

Is there any nice way around this in the expression?  
@nminchin 's last question in his older [post](https://forum.inductiveautomation.com/t/disabled-tag-breaking-expression-tag-expression/15092) was never answered.

> Shouldn’t this tag simply be ignored if it’s disabled?

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 19, 2023, 4:13pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/2 "2023-10-19T16:13:58Z")

</div>

> [@amarks](#):
>
> Shouldn’t this tag simply be ignored if it’s disabled?

It's nowhere near as simple as that. There's perhaps an argument to be made for this behavior if you're using the `tag()` expression, but if you're doing a pure interpolation I don't think there's a safe way to manage that.

Consider the following:

```auto
"Value: " + {SomeTag}

```

This scenario is simple enough; ignore the tag by interpolating the disabled tag as an empty string. Easy enough.

But this doesn't hold up for anything more complicated:

```auto
# int tags
"Value: " + str({SomeTag})
# or
3 + {SomeTag}
# boolean tags
false or {SomeTag}

```

The point is the interpolation doesn't know how the value is being used, and so there's no way to supply a safe "fallback" when the tag is disabled.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 4:19pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/3 "2023-10-19T16:19:11Z")

</div>

> [@cmallonee](#):
>
> ```auto
> # int tags
> "Value: " + str({SomeTag})
> # or
> 3 + {SomeTag}
> # boolean tags
> false or {SomeTag}
> 
> ```
> 
> The point is the interpolation doesn't know how the value is being used, and so there's no way to supply a safe "fallback" when the tag is disabled.

Would false/0 not be a safe interpretation in all cases?

`'Value: ' + str(0)` = 'Value: 0'

`3 + 0` = 3

`false or 0` = false

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 19, 2023, 4:21pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/4 "2023-10-19T16:21:24Z")

</div>

What about for your string usages?

```auto
"Value: " + {SomeTag}

```

would become... what?

```auto
Value: false
Value: 0

```

Neither is correct for a disabled string Tag.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 4:24pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/5 "2023-10-19T16:24:07Z")

</div>

Presumably either would be at least acceptable, considering there are many more correct use cases for other tag types. Also, if the tag is disabled you're most likely hiding whatever component is displaying the value based on that enabled property.

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [October 19, 2023, 4:29pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/6 "2023-10-19T16:29:04Z")

</div>

Would the try() method help out in your case?

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

You could do something like:

`try( {Some Expression #1}, {Some Expression #2} )`

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 4:30pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/7 "2023-10-19T16:30:48Z")

</div>

most likely, but in this specific case I'm just going to change the disabled tag in question to a memory tag and set the value to false.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 19, 2023, 4:33pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/8 "2023-10-19T16:33:24Z")

</div>

> [@amarks](#):
>
> Also, if the tag is disabled you're most likely hiding whatever component is displaying the value based on that enabled property.

That requires an insane amount of foresight and planning. It's highly unlikely anyone can predict the potential of disabling a Tag months or years in the future and incorporate that into all usages of that Tag.

> [@amarks](#):
>
> Presumably either would be at least acceptable

I suspect there's a large contingent who would argue that both of those values are wrong as neither are strings. These examples are also over-simplistic, with their point being there's no way to return any singular value type which would prevent ALL expressions from entering a configuration error state were ewe to go the route of returning some value were the Tag disabled.

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 4:35pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/9 "2023-10-19T16:35:48Z")

</div>

I don't know the source code, but could the value returned from a disabled tag be dependent on the type? (i.e. disabled numbers return 0, disabled bools return false, disabled strings return either null or '')

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 19, 2023, 4:46pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/10 "2023-10-19T16:46:39Z")

</div>

Even if we were to determine the returned value type based on the Tag type, we can't return a value which is not accurate; returning `0` could lead someone to falsely believe that tag is currently holding a value of `0`. On the front-end, they have no idea the Tag is disabled.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [October 19, 2023, 9:21pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/11 "2023-10-19T21:21:58Z")

</div>

> [@amarks](#):
>
> Shouldn’t this tag simply be ignored if it’s disabled?

How naïve I was! Thanks for reminding me 😅

Nowadays I would use `isAvailable` from the ignition extensions module to check if the tag is not disabled and found and incorporate that into the expression. Otherwise, as Cody said, there's no way to know what _you_ want the disabled value to be at any given time and project. Today it might be 0, tomorrow it might be 1, or 'invalid', or -1

---

<div class="post-metadata">

**Author:** ![amarks](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/amarks/32/45610_2.png) [@amarks](https://forum.inductiveautomation.com/u/amarks)\
**Post date:** [October 19, 2023, 9:26pm UTC](https://forum.inductiveautomation.com/t/disabled-tag-in-expression-causes-error/80704/12 "2023-10-19T21:26:42Z")

</div>

> [@nminchin](#):
>
> there's no way to know what _you_ want the disabled value to be at any given time and project. Today it might be 0, tomorrow it might be 1, or 'invalid', or -1

Sounds like a new tag property to me (`disabledValue`) 😅
