How to disable UI action for a specific user role but it should be enable for admin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2022 12:01 PM
Hi,
I need to disabale a UI action for a custom role with non admins, I have used !gs.hasRole('custom-role') like this,
when I use it , it will disable the UI action , form button even for admin users.
But I don't want it to happen. For All non admin users with custom-role should only this button should be hidden/ disable.
What I guess, for the root cause for this issue is gs.hasRole() is always returns true for admin users.
Please help me I'm stuck with this issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2022 10:29 PM
Hi,
I see, in this case gs.hasRole() will not work.
Please use below logic:
(gs.getUser().getRoles().indexOf('custom_Role')>-1) ---> Return true if loggedIn user having custom_role else return false
User it in your UI Action condition accordingly.
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2022 10:45 PM
Hi
Please update the condition as provided below:
(!(gs.getUser().getRoles().indexOf('custom_role') >= 0) || gs.getUser().getRoles().indexOf('admin') >= 0)
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik