Hello,
I am currently trying to enable a button when administrator users role are logged in from perspective and disable a button when only regular users are logged in.
I think the issue is what Kevin had mentioned. You are trying to compare a list to a string. You could check if 'Administrator' is in the list of roles if "Admin" in role:. A simpler approach may be to use an expression binding directly on the enabled property of the button. indexOf('Administrator',{session.props.auth.user.roles})>-1 might work correctly in the expression binding.
In expressions, hasRole(role, username, usersource) will also work (the second and third argument are required for Perspective):
You'll need to get username and user source from the session props, here's a more specific example. I just included the other one because of the nice screenshot:
To make it clear, you should never use the startup script to disable graphic components directly (not that you can). You should always use a binding on the component, or, in rare circumstances, a script from another graphical component in the same view.
Consider the situation where you need to add other conditions to the enable button as well. If you use a startup script, you're screwed (so too are you using another component script without thinking, hence why I said that would be rare)