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

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?

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

hasRole("Manager")

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

1 Like

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

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?

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

I was talking about the built in security functions that each component or window can be setup with. This manual page talks about it.