how to make a section on the form visible to an assignment group

Joshuu
Kilo Sage

Hi All,

 

I have the below requirement.

 

The below 'notifications' section and the fields from the below screen shot visible only to a specific group.

 

Please assist.

 

priyarao_0-1726152547868.png

 

Regards.

 

 

 

8 REPLIES 8

Anurag Tripathi
Mega Patron
Mega Patron

Hi,

You can use a display business rule and set the scratchpad variable as below

 

 

g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');  

 

 

Then Write an onload client script like below to show section

 

function onLoad() {

  if (g_scratchpad.grp){

g_form.setSectionDisplay('<pass section name>', true); 
    }
else
{
g_form.setSectionDisplay('<pass section name>', false); 
}


}

 

-Anurag

Hi @Anurag Tripathi ,

 

I have tried this, but the users who are not part of the group are still to be able to view the section.

You'll need to post your business rule definition and the client script.  in the BR, use the sys_id of the group record. and add lines in the client script for each field you want to show/hide.  But then it seems you want to hide the form section. for that you can use google to see how to do that, search "servicenow hide form section".

Can you show the scripts you are using?

Also add some logs in the client script to see what are you getting in the if else and is that getting executed correctly.

Is there any other script that may be setting the section display?

-Anurag