Get tag quality in an expression

I’m looking for a way to tell if a tag is enabled or disabled in an expression, and bind that to a property.

I want to control a button visibility based on the tag’s quality. If the tag quality is disabled, then not visible.

isGood doesn’t seem to work and I don’t see any way to get to the quality (in an expression) directly.

Not sure this is the best option but you could reference the tag Quality meta property directly:

{[default]path/to/tag.Quality}

@WillMT10 suggestion seems to be the easiest method. Just use an expression binding then use the tag browser to select the tag’s quality meta-property, nothing else needed unless you need it as a boolean then

if({[default]path/to/tag.Quality} = 'Disabled',0,1)

{[default]path/to/tag.Quality} != 'Disabled' would probably suffice.

3 Likes

Syntactically shorter, but more confusing in my opinion

thanks. So the complete expression that works is:

tag({template/tag/path}+’/some/sub/tag.Quality’) != ‘Disabled’

From one of the many @pturmel teachings, I’d recommend creating a custom property that is an indirect tag binding to {template/tag/path}+’/some/sub/tag.Quality’. Then change your expression to

{new_custom_property} != 'Disabled'

Seems to make sense, not having having that hard-coded in an expression binding. But what problem/issue does that solve? Can you site a use case doing it one way and the other?

From that same thread I linked above:

If you were to use tag() functions extensively, it can get A LOT more sluggish than using indirect tag bindings (learned this the hard way...).

1 Like

Thanks. Had I only followed your link I could have answered that myself. Thanks for being polite.

1 Like

Just note, in v8 the quality strings have changed. Disabled becomes Bad_Disabled

Also, IA have always recommended against using magic strings to compare quality, as you can see, they may be changed in future versions. Although there's no alternative at the moment in the expression language if you want to check for a specific quality. isGood({[default]path/to/tag}) should work, stealing Jordan's tag path from his post. Note: don't include the ".Quality" on the end, as the quality when reading the quality of a tag itself will always be good

In v8, you actually get an Enabled property, going back to the OP.