How to hide all the variables on RITM and task form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 03:13 AM
Hello All,
I need to hide all the variables on RITM and catalog task form for one specific catalog item.
Please help.
Thank you,
Priya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 05:21 AM
Hi,
Please uncheck Applies on a Catalog Item view checkbox
try to check in alert what comes
function onLoad() {
alert(g_scratchpad.Variables);
if(g_scratchpad.Variables != ''){
var emptyVars = g_scratchpad.Variables.split(',');
for(i = 0; i < emptyVars.length; i++){
g_form.setDisplay(emptyVars[i], false);
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 05:38 AM
Hello Ankur,
It is working now. I have modified the BR's to display.
But i have few more doubts as below.
Now I am not able to see the variables on catalog form too.
And also can we exclude for one particular group here. Like apart from that group noone else should see those variables.
Is that possible?
Please help.
Thank you,
Priya.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 05:42 AM
Please find responses below
1) Now I am not able to see the variables on catalog form too.
This BR and onLoad is not the reason for hiding those variables; as the client script won't run on Catalog Item View.
Please ensure that checkbox is false for Applies to Catalog Item view
Also check any other client script or UI policy is hiding the variables
2) Regarding group you can do this
Both the BR Script:
var variables = current.variables.getElements();
var arr = [];
for (var i=0;i<variables.length;i++) {
var variableName = variables[i].getQuestion().getName();
arr.push(variableName.toString());
}
g_scratchpad.Variables = arr.toString();
g_scratchpad.isMemberOf = gs.getUser().isMemberOf('Group ABC');
Client Script:
function onLoad() {
// if logged in user is not member of that group then hide
if(g_scratchpad.Variables != '' && g_scratchpad.isMemberOf.toString() == 'false'){
var emptyVars = g_scratchpad.Variables.split(',');
for(i = 0; i < emptyVars.length; i++){
g_form.setDisplay(emptyVars[i], false);
}
}
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 08:29 AM
Glad to know that it worked.
Please mark my response as correct and helpful to close the thread and to benefits others from this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-10-2020 11:47 PM
Glad to know that it worked.
Please mark my response as correct and helpful to close the thread and to benefits others from this.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader