Is it possible to modify the properties of a multi-state button on a per-button basis? For example, say I have a Hand-Off-Auto selector with three levels of security depending on what user is logged in. I want “level 1” to be able to see the buttons but not select any, I want “level 2” to see all buttons but only be able to select Off or Auto, and I want “level 3” to be able to select any of the buttons. Is this possible?
In this case it might be better to use separate buttons!
If you really want to use a multi-state button, I would create a custom property on the Multi-State Button called ControlValue2. Then add the code below to the Multi-State Button property change event. It will only update ControlValue2 if your user meets the roles requirements.
if event.propertyName == 'controlValue': userName = system.security.getUsername() user = system.user.getUser("", userName) userRoles = user.getRoles() if 'level 3' in userRoles: event.source.ControlValue2 = event.newValue elif 'level 2' in userRoles: if event.newValue != '2': event.source.ControlValue2 = event.newValue
Bind ControlValue2 to the Indicator Value to update the display of the Multi-State Button.
Now, instead of using ControlValue, just use ControlValue 2 in your logic.
You could also bind the Enabled property to this expression
hasRole("level 2") || hasRole("level 3")
Separate buttons it is! Thanks!