hasRole expression in Vision Client Tags not working

Good morning,

I'm trying to bind the "Show Ack Button" property of the Alarm Status Table to a Vision Client Tags, but it is not working as expected.

I've created a boolean expression tag in the Vision Client Tags called Role. The code is very simple:

! hasRole("Guest")

I expect that if the log in role is different from "Guest" my tag is True and viceversa, but it isn't working at all, it never change the status.

Actually I'm binding the "Show Ack Button" property of the Alarm Status Table directly with the same expression

! hasRole("Guest")

and it works perfectly. It looks like if I bind it with a Vision Client Tags it's not working.

Where is the error?
The version of Ignition is 8.1.23

I've solved in this way always in the expression:

{[System]Client/User/RolesString} != "Guest"

I don't know why hasRole is not working.

Hm. hasRole is working the way I would expect in a client tag for me. Were you testing in the designer, or a full client instance?

1 Like

I tested in both way, designer and full client instance. It looks very strange because if I use hasRole directly in the Alarm Status Table binding it works, but if I use in the client tag it has no effect.

I have the same issue, I have a Vision Client Tag "EnableSecurity" with an expression:
hasRole("Administrator") || hasRole("Engineer") || hasRole("Supervisor")

On a button .enable is tag [client]EnableSecurity
The button is enabled in the Designer but not in the Client instance (version 8.1.25)

Edit: This works correctly if referencing {[System]Client/User/RolesString} as Aiasa21 mentioned:
if((indexOf({[System]Client/User/RolesString}, "Administrator") >= 0) ||
(indexOf({[System]Client/User/RolesString}, "Engineer") >= 0) ||
(indexOf({[System]Client/User/RolesString}, "Supervisor") >= 0),true,false)

While this is an old topic, I'm experiencing the same issue in 8.1.45, so guessing this still hasn't been fixed. But I think there's just nothing to trigger a change, so I left the hasRole expressions but added this to the end:

&& {[System]Client/User/Username} != ''

So now as an example my expression looks like this for my operator role client tag:

hasRole('Operator') || 
hasRole('Supervisor') || 
hasRole('Technician') || 
hasRole('Engineer') || 
hasRole('Administrator') &&
{[System]Client/User/Username} != ''

While I could put all the hasRole expressions inside a parenthesis, it doesn't really matter since we have to have a username for the last one to evaluate to true anyway.

Now since it's referencing an actual tag, when the username changes, this triggers an update and all the roles are re-evaluated.

1 Like