# Trying to use if and contains together on the userrole tag to return boolean value

**URL:** <https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637>\
**Category:** Ignition\
**Created:** [August 21, 2019, 2:22pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637 "2019-08-21T14:22:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [August 21, 2019, 2:22pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/1 "2019-08-21T14:22:01Z")

</div>

Good morning. Trying to return a true/false value on the user role tag in Ignition to enable certain buttons being visible or not. I've just created a label with the following expression:

> if ({[System]Client/User/RolesString} = 'Manager','True','False')

I know the "=" is the wrong thing to use here, but I'm not sure how to find what I'm looking for in the substring as my users can have multiple roles depending on their department and level in the company. In SQL I would just use the like %manager% but I'm not sure how to translate this over to Ignition, or the best practice to do it. Any ideas?

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [August 21, 2019, 2:28pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/2 "2019-08-21T14:28:29Z")

</div>

Why not just use the `hasRole` function? That one checks if the role matches one of the roles of the user.

```auto
hasRole("Manager")

```

The other option is to use `indexOf` and check if the result is positive.

---

<div class="post-metadata">

**Author:** ![dholt](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dholt/32/4458_2.png) [@dholt](https://forum.inductiveautomation.com/u/dholt)\
**Post date:** [August 21, 2019, 2:29pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/3 "2019-08-21T14:29:13Z")

</div>

I never thought of using the hasRole function, will try. Thank you kindly for the reply!

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [August 21, 2019, 2:37pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/4 "2019-08-21T14:37:32Z")

</div>

If your trying to hide a button based on a role why not just use the security settings for the object? Then you can select the roles and use the hide restriction instead of recreating it with an expression?

---

<div class="post-metadata">

**Author:** ![tohhy-pm17](https://avatars.discourse-cdn.com/v4/letter/t/e19adc/32.png) [@tohhy-pm17](https://forum.inductiveautomation.com/u/tohhy-pm17)\
**Post date:** [March 5, 2021, 8:22am UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/5 "2021-03-05T08:22:25Z")

</div>

Hi bpreston, can you please explain further for your answer ?

---

<div class="post-metadata">

**Author:** ![bpreston](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@bpreston](https://forum.inductiveautomation.com/u/bpreston)\
**Post date:** [March 5, 2021, 2:00pm UTC](https://forum.inductiveautomation.com/t/trying-to-use-if-and-contains-together-on-the-userrole-tag-to-return-boolean-value/27637/6 "2021-03-05T14:00:59Z")

</div>

I was talking about the built in security functions that each component or window can be setup with. This [manual page](https://docs.inductiveautomation.com/display/DOC81/Component+and+Window+Security) talks about it.
