Using Roles for Button Visibility in Perspective

This seems trivial, but I can’t seem to figure out why this will not work. I am trying to set a button’s visibility based on the session’s logged in user role. This is the expression I created as a binding to the button visibility - {session.props.auth.user.roles} = “Administrator”. I have checked the spelling and I have tried other roles. When editing the expression, it evaluates as false without any errors.

I created a label to display the user’s role and it correctly displays the role of the user that is logged in.

Why does this not evaluate correctly for the visibility?

Thanks!

1 Like

That property has a list of all the roles, so a straight compare won’t work.

The isAuthorized expression works for this application. See here:
https://docs.inductiveautomation.com/display/DOC80/isAuthorized

2 Likes

That worked. Thank you!