Hide UI Action button for the user who is not a member of corresponding assignment group

Bijay Kumar Sha
Giga Guru

I have a requirement to Hide one UI Action button on the form "Create Change" for the user who is not a member of corresponding assignment group. See the screenshot below:

BijayKumarSha_0-1673502850658.png

 

I've given read role to the users for this table, so that all the users have the access to view all the records in the table but can't edit any of the field. However, only one UI action button "Create Change" is visible to the user & user can click on that. This is because user has also ITIL role given. That's why this button is visible to the users. 

But my requirement is to hide this button on the record, if the user is not a part of the assignment group. 

 

Hence, there is a script include exist which says if the user has ITIL role, the UI Action button will be visible which returns True. And this script include is getting called in the code of "Create Change" UI Action button based on if it returns Ture or False.

BijayKumarSha_1-1673503223374.png

So, I need to put one more "&&" condition in this function which will check if the user is the part of corresponding assignment group or not. If the function will return False, then the button should not be visible to the user. 

 

Can anyone please help me to know what will be the code to add that one more condition this the script include? 

4 REPLIES 4

Voona Rohila
Mega Patron
Mega Patron

Hi @Bijay Kumar Sha 

 

to check assignment group membership, add below condition in UI action or in script include.

 

&& gs.getUser().isMemberOf(current.assignment_group.toString())

 

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Nuwan
Tera Contributor

Hi @Bijay Kumar Sha,

 

Append this after && 

!gs.getUser().isMemberOf('name of the assignment group');

  

RaghavSh
Kilo Patron

In the UI action condition add && and below condition:

 

&& gs.getUser().isMemberOf(current.assignment_group.toString());


Raghav
MVP 2023
LinkedIn

Surya-S
Tera Guru
&&gs.getUser().isMemberOf(current.assignment_group.toString());

Hi @Bijay Kumar Sha 
You can use the following condition mentioned above.