How to hide variables in Service Catalog

Mussie
ServiceNow Employee
ServiceNow Employee

Hi Guys,

I have got a requirement where I need to hide variables from displaying on sc_req_item form. The requirement are as follows:

- Hide all variables from displaying from some catalog items on Request Item (sc_req_item) form

- Hide some variables from displaying from some catalog items on Request Item (sc_req_item) form

Could you please suggest on how I can achieve this? I am new to the product so please be detailed in your answers.

Thank you,

Mussie

1 ACCEPTED SOLUTION

Hi Mussie,



You can use variable set for your variables.


Then you can hide the variable set using g_form.setDisplay('variable_set_name',false); in the catalog client script


Don't Forget to tick the applies to requested items.



Thanks,



Tadz


View solution in original post

17 REPLIES 17

fra
Giga Contributor

Put a container start and end around the variables and then hide or show the container. It will then hide/show all the variables within it.


Mussie
ServiceNow Employee
ServiceNow Employee

Thanks Francis,


I tried the following and none of them worked:



function onLoad() {


        if (g_form.getValue('cat_item') == 'a3a616826f8721000ad98bc44b3ee462'){


  g_form.setDisplay('variables.cont_var_start',false);


  }


}



function onLoad() {


        if (g_form.getValue('cat_item') == 'a3a616826f8721000ad98bc44b3ee462'){


  try {


  $("container_a3a616826f8721000ad98bc44b3ee462").hide();


} catch(error) {}      


  }


}



Mussie


Hi Mussie,



You can use variable set for your variables.


Then you can hide the variable set using g_form.setDisplay('variable_set_name',false); in the catalog client script


Don't Forget to tick the applies to requested items.



Thanks,



Tadz


I think this should work.


Mussie
ServiceNow Employee
ServiceNow Employee

Thanks guys, I will try and let you know. The problem I have is, I have got more than 80 variables without a variable set and this is a bit tedious but I will try by adding few variables to a variable set and check and if it works then I will proceed with the rest.


Mussie