I want to hide a button (UI Action) from users with a certain role
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2014 01:50 PM
In the condition of the UI Action, I currently have the following code: current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList()
I would like to keep anyone who has the role of auditor from seeing this UI Action (button), so I added: && !gs.hasRole('auditor')
The entirety of the condition is now: current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList() && !gs.hasRole('auditor')
I assumed that this would mean, that for a user to see this, they would have to not have the role of auditor. But when I impersonate an auditor, I still see the button.
What am I doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 02:14 AM
Eric,
You can use below script in condition. Just paste below script:
(current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList()) && !gs.hasRole('auditor')
Let me know if still you getting issues.
I believe now you can do what you want exaclty
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-14-2014 10:18 AM
I tried that, but it hid the button (UI Action) only from the admin, so I tried this:
(current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList()) && (gs.hasRole('admin') || !gs.hasRole('auditor'))
Now the admin can see the button, just like every other user, including those with auditor role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-24-2015 01:43 PM
Hi Eric,
Were you able to find a resolution to this? I"m running into the same issue where the !gs.hasRole("role") does not work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2015 03:08 PM
Ken,
Yes, I did. Here is what happened in a nutshell...
The original was like this:
current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList()
I updated it to this which didn't work:
current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList() && !gs.hasRole('auditor')
Ultimately, used this and it worked
current.canCreate() && !RP.getListControl().isOmitNewButton() && !RP.isRelatedList() && (!gs.hasRole('auditor') || gs.hasRole('admin'))
Notice that I added parenthesis to the last two qualifiers so that the (user is not auditor OR is admin). I hope it helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2015 03:31 AM
Hello,
I am running into same problem "!gs.hasRole('asset_viewer')" hides button from every single user in service-now. So i tried solution given above "(!gs.hasRole('asset_viewer') || gs.hasRole('admin'))".
Now in this case i am able to hide button from asset_viewer and admin is able to see it.But, what about other users? how i can show this button to them.
Thanks for the help in advance.