UI Actions - I want to hide the button in related list based on role of logged in user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 01:01 PM
Hi all,
I want to hide the button in related list based on role of logged in user. This is for Account table, case tab. There's an Add button that should be hidden for a new role I'm creating. I've tried gs.hasRole or gs.hasRoleExactly in the condition field but the button still shows up.
Condition is (typeof parent !== 'undefined') && current.canWrite() && !gs.hasRoleExactly('new_role_id').
The last two were added by me but it doesn't respond to any of these conditions and the button is always there. Any ideas?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 02:50 PM
Hi,
hasRoleExactly is a client side method for GlideUser API.
For the server side either you have to write an script include for similar functionality like hasRoleExactly or you can use hasRole method of gs.
Please mark the answer as correct, If I answered your query. It will be helpful for others who are looking for similar questions.
Regards
Saurabh
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-18-2022 11:54 PM
Hi @MS12 ,
Did you try from List Control Option?
Right click on related list and Configure=>List control=>Omit New button
You write script in "Omit New condition" or 'Omit Edit Condition'
Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 01:15 PM
Gunjan,
Thank you for the suggestion. The new button was already disabled. I found out the Add button was for adding cases already created to the account.
As Saurabh mentioned, I was ready to go the script include routes but I didn't have to since this was not letting users create new case. I could leave it as it is.
Thank you both for your feedback!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 01:39 PM
Hello @MS12
Navigate to the respective UI Action and add restriction for it.
Please mark my response as helpful/correct, if it works.