- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:02 AM
Hi All,
I have written below script. But still I'm not why another group members also getting same result.
Please check below script and let me know.
I have written onload client script.
var userID = g_user.userID;
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group_name', 'RCO - Limited Contract Read');
gr.addQuery('user', userID);
gr.query();
if (gr.next()) {
alert(userID);
g_form.setSectionDisplay('notes', false);
g_form.setSectionDisplay('documents', false);
g_form.setSectionDisplay('terms_andconditions', false);
g_form.setSectionDisplay('renewalextension', false);
g_form.setSectionDisplay('financial', false);
g_form.setSectionDisplay('technical_information', false);
}
Please help me here If I have done anything wrong here.
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:24 AM
Hi @Sirri ,
Please refer this KB and match with sections.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0696583
and use the setDisplay() instead of setSectionDisplay();
g_form.setDisplay(<sectionName>, false);
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:46 AM
Hi,
It is not advisable to use GlideRecor din cluent script, so I would suggest use a combination of client script and Display BR
Step 1: Create a display Business rule with script as below
g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');
Now update the client script as
function onLoad() {
var usr = g_user.getUserID();
var gate = g_form.getValue('u_field');
if (gate == 'true' && !g_scratchpad.grp){
g_form.setSectionDisplay('notes', false);
g_form.setSectionDisplay('documents', false);
g_form.setSectionDisplay('terms_andconditions', false);
g_form.setSectionDisplay('renewalextension', false);
g_form.setSectionDisplay('financial', false);
g_form.setSectionDisplay('technical_information', false);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:24 AM
Hi @Sirri ,
Please refer this KB and match with sections.
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0696583
and use the setDisplay() instead of setSectionDisplay();
g_form.setDisplay(<sectionName>, false);
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:46 AM
Hi,
It is not advisable to use GlideRecor din cluent script, so I would suggest use a combination of client script and Display BR
Step 1: Create a display Business rule with script as below
g_scratchpad.grp = gs.getUser().isMemberOf('PASS GROUP NAME HERE');
Now update the client script as
function onLoad() {
var usr = g_user.getUserID();
var gate = g_form.getValue('u_field');
if (gate == 'true' && !g_scratchpad.grp){
g_form.setSectionDisplay('notes', false);
g_form.setSectionDisplay('documents', false);
g_form.setSectionDisplay('terms_andconditions', false);
g_form.setSectionDisplay('renewalextension', false);
g_form.setSectionDisplay('financial', false);
g_form.setSectionDisplay('technical_information', false);
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-07-2024 08:57 AM
@Sirri Do you have any mandatory field in any of these sections? If yes then the section would not be hidden.
Also make sure that The section name is lower case with an underscore replacing the first space in the name, and with the remaining spaces being removed, for example "Section Four is Here" becomes "section_fourishere". Other non-alphanumeric characters, such as ampersand (&), are removed. Section names can be found by using the getSectionNames() method.