How to restrict UI action button for Particular Related List/List Control

Harish Kota2
Tera Contributor

I want to show the UI Action Related list for limited groups only and for Admins as well.

I have written the below code in 'omit new button'.

!gs.getUser().isMemberOf('assignment_group') || !gs.getUser().isMemberOf('assignment_group') || !gs.getUser().isMemberOf('assignment_group') || !gs.getUser().isMemberOf('assignment_group') && checked with || as well  !(gs.hasRole('admin'));

the above code is working for mentioned groups but not for Admins, Admins are not able to see the New button.

My Requirement is Admin and the mentioned group members only should see the New button as per the screenshots.

 

1 ACCEPTED SOLUTION

With omit new condition, "true" result hides the button, "false" shows the button. with your original code with the ! in place, you need to switch to "&&" instead of "||". This should result in the right results.

View solution in original post

4 REPLIES 4

Mohit Kaushik
Mega Sage
Mega Sage

Hi Harish,

In that case I guess you need to remove not from your condition:

gs.getUser().isMemberOf('assignment_group') || gs.getUser().isMemberOf('assignment_group') || gs.getUser().isMemberOf('assignment_group') || gs.getUser().isMemberOf('assignment_group') || (gs.hasRole('admin'));

 

Please mark this as correct and helpful if it resolved the query or lead you in right direction.

Thanks,
Mohit Kaushik
Community Rising Star 2022

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hi Mohit,

Tried but not working.

With omit new condition, "true" result hides the button, "false" shows the button. with your original code with the ! in place, you need to switch to "&&" instead of "||". This should result in the right results.

thank you Kristen, working fine now