Calling a System tag from a template

Is it possible to read a system tag in a template and see the value in the designer in run mode?
I am trying to read the [System].Client.User.RoleString, but in the designer in run mode it gives me a “None” value eventhough the tag has “Administrator” value?

How did you bind it? Works for me.
Does it work in the designer?

I used below concept
server = "Ignition OPC UA Server"

path = "[SLCSim]_Meta:N7/N7:0"
qualifiedValue = system.opc.readValue(server, path)
print "Value: " + str (qualifiedValue.getValue())
print "Quality: " + qualifiedValue.getQuality().toString()
print "Timestamp: " + qualifiedValue.getTimestamp().toString()

But now I have changed my code to do the following what seems to work.
roles = system.user.getRoles(“”)
for role in roles:
if role == “Administrator”:
RoleAdmin = True
RoleAdmin = False

Do you need the true false, or just the role displayed?

Actual my code is not working. it will always result in True because I have a role that is “Administrator”

What I am trying to accomplish is to check in the template if the current user has a role as
“Administrator”. This can be a true/false flag.

That was the reason I was trying to read the [System]Client.User.Rolestring.Value

But why do you need to know the users role? also you can test with a generic user you create.

What are you trying to do/hide/ etc…?

The reason is that if the user has a role status of “Administrator”
the user will be able to change the size of a circle and a bunch of more stuff, but if the user does not have that status of “Administrator” then he will not be able to see the components to change the size of a circle and a whole bunch of other stuff.

So the role will be used to hide or unhide components.

After some digging I am getting closer. I was on the wrong track. Now I have this code but the line
Roles = user.getRoles fails? I am not sure why

userName =
print “userName : " + userName
if userName == “Ignition”:
user = system.user.getUser(”", userName)
Roles = user.getRoles

When you add code, you need to use the pre-formatted block otherwise the text loses all formatting image


We’re not sure why either, as you haven’t given us the error message :slight_smile:

In scripting, to get the currently logged in user’s roles you can use:

system.user.getUser requires the user source, you can’t just leave this blank.

If you want to use it in an expression though, you should be able to read the tag [System]Client/User/RolesString as you said. You had dots instead of slashes though?
This is the error I get trying to read that tag path with dots instead:

Thank you Nick.
It works.
That was much simpler then what I was doing.

Also thank you for the code formatting tip. I am new to this forum and this will help me.