How to hide all the variables on RITM and task form

Joshuu
Kilo Sage

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.

21 REPLIES 21

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

 

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

Ankur Bawiskar
Tera Patron
Tera Patron

@priyarao 

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

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

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

 

Hello Ankur,

This is not working for me.

Can you please check the below screen shots.

find_real_file.png

 

find_real_file.png

 

find_real_file.png