# Evaluating tag write quality codes in scripts

**URL:** <https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [December 30, 2019, 9:53pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984 "2019-12-30T21:53:32Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dan\_Bridgeman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dan_bridgeman/32/3610_2.png) [@Dan\_Bridgeman](https://forum.inductiveautomation.com/u/Dan_Bridgeman)\
**Post date:** [December 30, 2019, 9:53pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/1 "2019-12-30T21:53:32Z")

</div>

What are the options for evaluating the quality code returned from system.tag.writeBlocking? I would rather have a comparison to a meaningful value like “Good” than a number like 192. Do we have access to built-in constants, or would I need to write my own?

Also, I see that in the expression language, there’s an isGood() function which returns True for any of the good tag quality values. Is there an equivalent available in scripting?

---

<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:** [December 30, 2019, 10:09pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/2 "2019-12-30T22:09:40Z")

</div>

You can compare to the enum if you really want to:

```auto
from com.inductiveautomation.ignition.common.sqltags.model.types import DataQuality
if tag.quality == DataQuality.GOOD_DATA:
   ...

```

The values are available in the [javadocs](http://files.inductiveautomation.com/sdk/javadoc/ignition79/795/index.html). Search for Quality, and then open DataQuality from the known implementing classes.

E.g.  
`DISABLED`  
`GOOD_DATA`  
`OPC_BAD_DATA`  
`NOT_FOUND`  
… etc.

Otherwise, you can also use str() to convert the DataQuality to a string and simply compare to “Good”, “Disabled”, “Not Found”, etc.

Also yes, you can use isGood() on the quality as well (also visible from the javadocs):

```auto
val.quality.isGood()

```

---

<div class="post-metadata">

**Author:** ![Dan\_Bridgeman](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dan_bridgeman/32/3610_2.png) [@Dan\_Bridgeman](https://forum.inductiveautomation.com/u/Dan_Bridgeman)\
**Post date:** [December 31, 2019, 6:51pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/3 "2019-12-31T18:51:27Z")

</div>

Thanks, Nick. The isGood method is exactly what I need.

---

<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:** [December 31, 2019, 10:04pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/4 "2019-12-31T22:04:18Z")

</div>

Psst! Nick!

```auto
val.quality.good

```

---

<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:** [December 31, 2019, 10:09pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/5 "2019-12-31T22:09:14Z")

</div>

Haha, i thought there might have been a Javabeans method, but the ‘is’ tripped me up. Cheers! And happy new year

---

<div class="post-metadata">

**Author:** ![jeffrey.boey](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jeffrey.boey](https://forum.inductiveautomation.com/u/jeffrey.boey)\
**Post date:** [February 9, 2022, 11:31am UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/6 "2022-02-09T11:31:23Z")

</div>

> [@nminchin](#):
>
> `val.quality.isGood()`

Hi, apologies if I'm resurecting a dead topic, out of curiousity I tried your method

> from com.inductiveautomation.ignition.common.sqltags.model.types import DataQuality
> 
> res = system.tag.readBlocking(["[default]Testing/test\_events/Ref\_to\_Trigger"])  
> print(res[0].quality)  
> print(DataQuality.GOOD\_DATA)  
> if res[0].quality == DataQuality.GOOD\_DATA:  
> print("I confirm that the quality is good")

Somehow, the IF statement is never true, although the 2 prints shows the exact same "Good" string.

I obviously opted for the isGood() method and it works, but I'm just curious why the the statement is false 😄

Cheers

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [February 9, 2022, 12:24pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/7 "2022-02-09T12:24:47Z")

</div>

im pretty sure the **sqltags library** is an outdated, so the enum probably is no good anymore or moved to a different location,  
what version are you running?

> [@Tags related changes from Ignition 7.9 to 8.1](https://forum.inductiveautomation.com/t/tags-related-changes-from-ignition-7-9-to-8-1/55587/2):
>
> (I’m not an expert in either the old or the new tag system) You will hopefully be able to switch to the new ManagedTagProvider concept; it’s a simpler scaffolding that helps with setting up the basic idea of “Java code that provides Ignition tags”. I’d start from the SDK example and work from there: As a general rule: Anything under the sqltags package is deprecated or outright removed.

Edit:  
yup seems this should work instead now on newer version:

```auto
from com.inductiveautomation.ignition.common.model.values import QualityCode	
res = system.tag.readBlocking(["[default]Components/oneShot"])
return QualityCode.Good == res[0].quality

```

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

---

<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:** [February 9, 2022, 12:28pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/8 "2022-02-09T12:28:40Z")

</div>

try printing the type of the tag quality e.g.:

```auto
print type(res[0].quality)

```

---

<div class="post-metadata">

**Author:** ![jeffrey.boey](https://avatars.discourse-cdn.com/v4/letter/j/6a8cbe/32.png) [@jeffrey.boey](https://forum.inductiveautomation.com/u/jeffrey.boey)\
**Post date:** [February 9, 2022, 1:19pm UTC](https://forum.inductiveautomation.com/t/evaluating-tag-write-quality-codes-in-scripts/30984/9 "2022-02-09T13:19:03Z")

</div>

AH you guys are so right, the sqltags library is outdated and the new library works. I missed the lack of sqltags in the path

Now I can sleep easy, it was bothering me for a while now 🤣

Cheers!!
