# System.tag.exists in expression error

**URL:** <https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563>\
**Category:** Ignition\
**Created:** [October 21, 2024, 7:35pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563 "2024-10-21T19:35:44Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bigtalljv](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bigtalljv](https://forum.inductiveautomation.com/u/Bigtalljv)\
**Post date:** [October 21, 2024, 7:35pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/1 "2024-10-21T19:35:44Z")

</div>

Hi,

I have been trying to use runScript("system.tag.exists", 0, {tag\_Path}) and I am seeing something weird. If the path doesn't exist the expression returns False, however, if the tag does exist then I get an error,

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

Any suggestions on what is going on? User error?

---

<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:** [October 21, 2024, 7:41pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/2 "2024-10-21T19:41:24Z")

</div>

Can you post the script of `system.tag.exists`? (Format it using the \</\> button.)

---

<div class="post-metadata">

**Author:** ![Bigtalljv](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bigtalljv](https://forum.inductiveautomation.com/u/Bigtalljv)\
**Post date:** [October 21, 2024, 7:44pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/3 "2024-10-21T19:44:14Z")

</div>

I'm not sure. Where do the system scripts live?

---

<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:** [October 21, 2024, 7:46pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/4 "2024-10-21T19:46:31Z")

</div>

Oops! It's getting close to bedtime here. I didn't recognise it as a built in function. I thought it was something you wrote. Carry on ...

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [October 21, 2024, 7:47pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/5 "2024-10-21T19:47:06Z")

</div>

you could probably also do this

```python
try(
	isGood({[.]tagPath}),
	False
)

```

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 21, 2024, 7:57pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/6 "2024-10-21T19:57:57Z")

</div>

I don't think you want the `{}` in the expression, as the argument you are passing is supposed to be a string representing a possible tag path, as opposed to the value of an actual tag.

```python
runScript("system.tag.exists",0,"path/to/tag")

```

I believe you are getting the error because the expression is trying to parse the tag path. When the path doesn't exist then it sends a value of "none", which incorrectly returns the correct value because the path "none" doesn't exist. When the path does exist, then it tries to send the value of the tag which probably can't be properly parsed to a valid path.

Personally, I would use the approach that @dkhayes117 showed, because then you don't have to pay the cost of starting up the interpreter.

---

<div class="post-metadata">

**Author:** ![Bigtalljv](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bigtalljv](https://forum.inductiveautomation.com/u/Bigtalljv)\
**Post date:** [October 21, 2024, 8:05pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/7 "2024-10-21T20:05:13Z")

</div>

Thanks, that was the issue. I was actually using relative paths from a property but had been using Tag() so it's the same idea. If I remove the Tag() then it appears to work like it should

My concern with isGood is that I have a bunch of radio based sites that can have enough delay to cause Bad statuses. Things would be blinking all over the place.

I'm not sure what the resource cost of the interpreter is but server wise I have a lot to work with.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 21, 2024, 8:33pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/8 "2024-10-21T20:33:12Z")

</div>

If you are concerned with bad statuses, then you can use the `isBad()` or `isBadOrError()` expressions.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 21, 2024, 9:32pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/9 "2024-10-21T21:32:56Z")

</div>

For posterity, I'll note that the `system.tag.exists` function is just doing a tag read of the `.Name` subproperty (because `.Value` can be expensive to read for some types of tags). So if you already have a path to a tag, `qualityOf({that/tag/path.name}) != "Bad_NotFound"` will give you the exact same result as `system.tag.exists`.

---

<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 22, 2024, 2:51am UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/10 "2024-10-22T02:51:54Z")

</div>

> [@lrose](#):
>
> `isBad()` or `isBadOrError()`

Or `isAvailable()` from Paul's [Ignition Extensions](https://forum.inductiveautomation.com/t/ignition-extensions-convenience-utilities-for-advanced-users/64615/5) module, which checks if the tag is both not disabled and exists, because those are the only two states in which you would want to hide something using, otherwise you would be masking a genuine issue. (to test for these two qualities without `isAvailable` is a horrible monster of an expression)

Still hoping that this makes it into the product!!!!

---

<div class="post-metadata">

**Author:** ![Bigtalljv](https://avatars.discourse-cdn.com/v4/letter/b/e19adc/32.png) [@Bigtalljv](https://forum.inductiveautomation.com/u/Bigtalljv)\
**Post date:** [October 22, 2024, 2:23pm UTC](https://forum.inductiveautomation.com/t/system-tag-exists-in-expression-error/97563/11 "2024-10-22T14:23:56Z")

</div>

thanks. there is a lot of very cool, and pretty much required parts for my operators, that exists but hasn't made it into the product, Paul's extensions and the Ad-Hoc Trends and Rosters come to mind.
