Check if utd tag has string value and change the color of the label

I would like to know if there is a script that checks if a utd tag (string) is not null and then change the color of a label based on whether the tag has a string or not

Since you are using a string tag you can just easily check the actual string:
if({New Tag} = ‘null’, “RED”,“GREEN”) and use this in the foreground or background property of the label.
Or add a expression tag to your udt and call it qualityCheck and use that expression code and get a 1 or 0 and use the 0,1 to change the color of the label.

I tried to get this working on the a tag using the valueChange scripting but had some issues, couldn’t get the system.gui to work(object has no attribute gui). I think a script like that has to run on either the client event script or gateway event script (as far as I know, I might be wrong).

What you are trying to do is very simple, you should give the expression a try, I use it a lot and absolutely love it. Now if you specifically have to use scripting thats another issue and I’m sure someone else will have an idea on the scripting end and can help you.

Thank you, just one more quick question would I be able to replace red and green with rgb code

Yes you can, just use RGB code instead of the name of the color and works just fine.

You can do RGB (255,255,255) Or HEX (00ff00) which will give you the same, just figured to mention that you can go that route as well… some people knows HEX values better than RGB… good luck and expression away, its great!!!

I’m working on the same sort of thing. However, I have a question:

In my text field set as a string, there simply is no information if the data is deleted. It’s not null, and it’s not 0, just blank? Is there a way to compare it to something?

just compare it to “”, if you are comparing it to a string value.

Awesome! Thanks.
Seems to be working, though the fields are initially colored (1 state). For some reason, just clicking on them once sets the state to 0.

1 Like