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

Hi Maynak,


Thank you for your reply. This doesn't seem to work, please check my screen, this won't hide the first name variable. Any ideas?Screen Shot 2016-03-04 at 3.17.49 PM.png


Hi Mussie,



Try clicking on advance view. This should bring all the fields on form.


Then check the one which says 'Applies on Requested Item'. That should of the trick.


Mussie
ServiceNow Employee
ServiceNow Employee

Any idea why this isn't working for me? The sys_id for the specific catalog item is correct and I have got a variable with the name firstName on the item.



function onLoad() {


    //Type appropriate comment here, and begin script below


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


  g_form.Mandatory('variables.firstName', false);


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


  }


}



Mussie


From what I can see, if you are using the exact same script there is a syntax error:


  g_form.Mandatory('variables.firstName', false);


should be


g_form.setMandatory('variables.firstName', false);



Also, I don't think that you need to use "variables.variable_name" in catalog client scripts. you can try just the variable name.


Thank Mayank, I don't know how I missed it, that solves part of my problem. I need to put a variables.variable_name though. Do you know how I can hide all the variables without specifying the each and every variable? I've got more than 50 variables and this makes it really tedious to list all in the code.


Mussie