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 04:28 AM
Hello Priyarao,
If you want to remove all variables just to that table -> go to the form_design section and remove the "Variable editor" as every variable will inside that variable editor box. that will remove all the variables from the requested item table and catalog task table.
you don't need code as you have no-code solution
Please Mark it helpful/correct if my answer helps in any way to resolve your query.
Reach out to me if any more help required.
Regards
Yash.K.Agrawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-11-2020 12:35 AM
Hello Priya
You can hide the entire section simply using the code below in an onload client script
function onLoad()
{
if(item=='catalog item name')
{
var sections = g_form.getSections();
sections[4].style.display = 'none'; //make sure you number the right section that has the variables editor
}
}
Please mark my answer correct/helpful if it helped you solve your issue.
-Anurag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 03:39 AM
why do you require to hide all the variables on RITM and catalog task form for that specific item?
What is the business use-case or requirement here
you can achieve this using below steps
1) create display BR on sc_req_item table
2) Create onLoad catalog client script which applies on RITM and TASK form
Display BR on sc_req_item table
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();
Display BR on sc_task table
var variables = current.request_item.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();
Catalog Client Script which applies on RITM and TASK both
function onLoad() {
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 03:52 AM
Hello Ankur,
Please check my edited answer, from the way I suggested, it will hide variable on ritm and task based on the variable selected in UI policy action.
Reagrds,
Yash.K.agrawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-09-2020 04:41 AM