UI Actions - I want to hide the button in related list based on role of logged in user

MS12
Kilo Sage

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!

MS12_0-1668805250857.png

 

 

4 REPLIES 4

Saurabh Gupta
Kilo Patron
Kilo Patron

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

Gunjan Kiratkar
Kilo Patron
Kilo Patron

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' 

GunjanKiratkar_0-1668844388912.png

 

 

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

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!

Raghu Ram Y
Kilo Sage

Hello @MS12 

Navigate to the respective UI Action and add restriction for it.

Please mark my response as helpful/correct, if it works.