[FEATURE] Add expression function to check if tag is valid (exists and not disabled)

I should have asked for this a very long time ago to be honest…

I would like a function to check if a tag is valid. What I mean by this, is that it both exists and is not disabled. No other qualities should affect the value returned.

Often I will create templates / view templates that can accommodate multiple UDT definitions and/or instance configurations. E.g. differences in the tags available between similar UDT defs or tags that are disabled in particular instances of the UDTs. To accommodate these, I will check the quality of tags and hide the graphic component if the associated tag isn’t valid.

For these cases, currently I’m simply using isGood(), but technically this can be deceptive. If a tag is in fact valid for a UDT but has a configuration error for example, or is stale, waiting for initial value, etc. etc. then the graphic component using isGood will hide the display for it and essentially mask the issue, and will confuse the operator who is expecting to see the thing that is hidden.

The alternative currently is incredibly dopey and long-winded. I would have to do something like:

indexOf(toStr(qualityOf({tag})), 'Bad_NotFound') = -1 &&
indexOf(toStr(qualityOf({tag})), 'Bad_Disabled') = -1

I would like a new function explicitly for testing this, like isValid or similar so that I can just use:

isValid({tag})

Vote here:

I really wish I knew how to write my own module :frowning:

3 Likes

Yes please. The two properties we want to confirm for the same reason are exists and enabled. isGood is great, but doesn't help with this use case.

2 Likes

isValid({tag}) might imply more than exists and enabled.

isEnabled({tag}) seems like a reasonable option. It would return false for disabled and false for doesn’t exist (can’t be enabled if it doesn’t exist).

Yeah, I agree that ‘valid’ isn’t quite right. I don’t think ‘enabled’ is either though :thinking:

But I can’t think of anything else that I’d use that conveys both…

existsAndEnabled

How about isAvailable()?

Great idea by the way

3 Likes

For posterity, this was added into Paul's Ignition Extensions module:

It would still be nice for this to be added into the product, since this will be unusable in Edge projects :frowning: