AnsweredAssumed Answered

Check if an attribute is pointing to a tag that exists and if exists returns the tag value

Question asked by wilson.laizo on Feb 24, 2017
Latest reply on Feb 27, 2017 by rdavin

Hello All;

 

We have a case here where we have a template with some attributes and sometimes the equipment will have tags, sometimes it wont and as that is configurable by the user, is not possible to create a template for each case.

 

So, what we want to do is to check if the attribute is pointing to a tag that exists and if it exists returns the value of the tag and if not, returns the text "Disabled".

 

In everything that I tested, the Evaluate function would work, but when I start the calculation it will give me the error "Failed to to signup any input for receiving updates".

 

First I tried to use BadTag('attribute') to check if the tag exists. Evaluate works and when I run analysis it fails.

If BadVal('attribute') Them "Disabled" Else "Enabled"

 

After I went to the documentation that suggests to use the tag directly. So, if I do like the code below it will work both on Evaluate and Analysis, but it does not produce the expected result (tag value if find the tag).

If BadVal(TagNum("tagname")) Then "Disabled" Else "Enabled"

 

When I try to replace the "Enabled" by the attribute it will Evaluate but the calculation will fail:

If BadVal(TagNum("tagname")) Then "Disabled" Else 'attribute'

 

TagVal only accepts attributes, so, I cannot use that to get the tag value directly, and using the attribute it will fail.

 

I also tried using Formula and I end up in the same kind of restriction as it does not work with strings, so, I end up with a digital state:

A=.|Value;[if badval(A) then 0 else 1]

 

Do you guys have any idea on how I can solve this problem?

Outcomes