- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:32 AM
Hi Team
need to hide certain sections for three different groups of users, which are determined by system properties.
To achieve this, I will write an onload client script and a display business rule. The sections should be hidden based on the logged-in user.
Client script
function onLoad() [
//Type appropriate comment here, and begin script below
//// var sec=gform.getSections();
var grpmember = g scratchpad.hideSections;
if (grpmember) [
var grpArr = grpmember.split(",");
if (grpArr.includes(g scratchpad.groupvertical)) (
g_form.setSectionDisplay('executive_notification', false);
}
}
}
Business rule
(function executeRule(current, previous /null when async*/) {
// Add your code here
g scratchpad.hideSections = gs.getProperty('xoc.incident.show_exec_notification');
g.scratchpad.groupvertical = current.assignment_group.parent.getDisplayValue():
}(current, previous);
system property with group names: XOC-NED,XOC-WSt
But still not working as expected. Could you please me on this issue
Thank you in advance
Siva
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 03:45 AM
are you saying if logged in user is member of any of those 3 groups then hide the section?
OR
are you saying if the form has any 1 of those 3 groups then hide the section?
I assume you are talking about the 1st case. If yes then this will work
(function executeRule(current, previous /null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", gs.getUserID());
gr.addQuery("group.sys_id", "IN", gs.getProperty('xoc.incident.show_exec_notification'));
gr.setLimit(1);
gr.query();
g_scratchpad.isMember = gr.hasNext().toString();
}(current, previous);
onLoad client script
function onLoad() {
if (g_scratchpad.isMember == 'true')
g_form.setSectionDisplay('executive_notification', false);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:46 AM
what's being stored in this property ->
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 02:57 AM
Hi @Ankur Bawiskar ,
Thank you for your quick reply. We have stored group names that system property
Thank you
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 03:45 AM
are you saying if logged in user is member of any of those 3 groups then hide the section?
OR
are you saying if the form has any 1 of those 3 groups then hide the section?
I assume you are talking about the 1st case. If yes then this will work
(function executeRule(current, previous /null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("user", gs.getUserID());
gr.addQuery("group.sys_id", "IN", gs.getProperty('xoc.incident.show_exec_notification'));
gr.setLimit(1);
gr.query();
g_scratchpad.isMember = gr.hasNext().toString();
}(current, previous);
onLoad client script
function onLoad() {
if (g_scratchpad.isMember == 'true')
g_form.setSectionDisplay('executive_notification', false);
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2024 05:22 AM