How to enable a component in for a particular user

hi,
I want to enable a component for particular user with particular role, i have write down a script it doesn't seems to be working.

What about an expression -
hasRole - Ignition User Manual 8.1 - Ignition Documentation.

hasRole('Manager') || hasRole('Supervisor')

1 Like

Or, even better, Component Security?

https://docs.inductiveautomation.com/display/DOC81/Component+and+Window+Security

6 Likes

what is I want do it with scripting.

You really shouldn't; you should use component security because it's better for future maintenance (more performant, more reliable, easier for the next person to understand) but if you insist on doing it with scripting, your script in the OP can be rewritten to:

allowedRoles = ["Manager", "Supervisor"]
userRoles = system.security.getRoles()
event.source.enabled = any(role in allowedRoles for role in userRoles)
7 Likes