how to make a section on the form visible to an assignment group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 08:00 AM
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.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 08:33 AM
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);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 10:16 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2024 11:07 AM
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".
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-13-2024 02:35 AM
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?