- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:23 PM
Hi Team,
Please help me on the below requirement.
I have hide the attachments based on the states for this i have written on load client script, now i want for Change Management groups members need to accessible in all states.
I have written below script to hide the attachments.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-29-2023 11:36 PM
that group has some role? if yes then add that check in script
function onLoad() {
var state = g_form.getValue("state");
if(!g_user.hasRoleExactly('roleName')){
if (state == '-2' || state == '-1' || state == '4' || state == '3' || state == '0'){
g_form.disableAttachments();
}
}
}
If your group has no role then you can use display business rule and check if logged in user belongs to that group and use g_scratchpad variable
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');
})(current, previous);
Client script
function onLoad() {
var state = g_form.getValue("state");
if(g_scratchpad.isMember.toString() == 'false'){
if (state == '-2' || state == '-1' || state == '4' || state == '3' || state == '0'){
g_form.disableAttachments();
}
}
}
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
08-29-2023 11:36 PM
that group has some role? if yes then add that check in script
function onLoad() {
var state = g_form.getValue("state");
if(!g_user.hasRoleExactly('roleName')){
if (state == '-2' || state == '-1' || state == '4' || state == '3' || state == '0'){
g_form.disableAttachments();
}
}
}
If your group has no role then you can use display business rule and check if logged in user belongs to that group and use g_scratchpad variable
(function executeRule(current, previous /*null when async*/) {
// Add your code here
g_scratchpad.isMember = gs.getUser().isMemberOf('Group Name');
})(current, previous);
Client script
function onLoad() {
var state = g_form.getValue("state");
if(g_scratchpad.isMember.toString() == 'false'){
if (state == '-2' || state == '-1' || state == '4' || state == '3' || state == '0'){
g_form.disableAttachments();
}
}
}
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