# hasRole expression in Vision Client Tags not working

**URL:** <https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [February 2, 2023, 9:59am UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333 "2023-02-02T09:59:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [February 2, 2023, 9:59am UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/1 "2023-02-02T09:59:53Z")

</div>

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:

```auto
! 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

```auto
! 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

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [February 2, 2023, 12:08pm UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/2 "2023-02-02T12:08:23Z")

</div>

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

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

I don't know why hasRole is not working.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [February 2, 2023, 5:13pm UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/3 "2023-02-02T17:13:41Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Aiasa21](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@Aiasa21](https://forum.inductiveautomation.com/u/Aiasa21)\
**Post date:** [February 2, 2023, 7:24pm UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/4 "2023-02-02T19:24:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Wayne\_Wessel](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@Wayne\_Wessel](https://forum.inductiveautomation.com/u/Wayne_Wessel)\
**Post date:** [March 6, 2023, 8:46pm UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/5 "2023-03-06T20:46:18Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [February 21, 2025, 8:32pm UTC](https://forum.inductiveautomation.com/t/hasrole-expression-in-vision-client-tags-not-working/69333/6 "2025-02-21T20:32:42Z")

</div>

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:

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

```

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

```python
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.
