Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to hide all variables from catalog item?

Ashwini Jadhao
Giga Guru

Hi,

How to hide all variables from catalog item.

I am trying it with UI policy but I have 15 Ui policies on same catalog item and also I have given order to all UI policies.

but it is get override on other UI policy.I have written this script but it is not working properly

var dbtype = g_form.getValue('Department');
var subType = g_form.getValue('subDepartment');
if (dbtype == '' && subType == '') {
var fields = g_form.getEditableFields();
 for (var x = 0; x < fields.length; x++) {
 g_form.setMandatory(fields[x], false);
g_form.setDisplay(fields[x], false);
}

this not working properly when I change the dbtype and subType values.I written script in else if condition as well.

or I need to write as below for all variables because it is working

g_form.setMandatory('monthlySchedule', false);
g_form.setDisplay('monthlySchedule', false);

}

 

For multiple choice variable type above APIs not working

multiple choice variable : Department 

Mandatory : true

g_form.setMandatory('department', false);
g_form.setDisplay('department', false);

 

6 REPLIES 6

Gaurav Shirsat
Mega Sage

Hello

I have read the previous answer,also you can acheive your goal by doing this

use 

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

also you can use catalog UI Policy:-

Catalog UI Policy

  • A catalog UI policy applies to either a specific catalog item or any item that uses a specific variable set.
  • A catalog UI policy can only contain and reference variables that are defined for the catalog item or variable set.
  • Also, if the variables are generic or universal in nature you can create a variable set and attach the UI Policy to that variable set. So that the same set can be used in multiple Catalog Items.
  • The best way to do this in my opinion is using a Catalog UI Policy. Just tick the 'Applies on Requested Item' check-box.

Catalog UI Policy always has precedence over the UI Policy

refer the below link for more details

https://docs.servicenow.com/bundle/orlando-it-service-management/page/product/service-catalog-manage...

Please marak correct and helpful

Thanks and Regards

Guarav Shirsat

Pooja Yadav3
Mega Expert

Hi Ash,

The given below link will help you to get the solution:

https://community.servicenow.com/community?id=community_question&sys_id=7f6834aedbfaab004abd5583ca96...

 

Since you need to hide all the variables ,the above link will help you.

firstly,making a variable set and then applying the actions like catalog UI policies/catalog client scripts .

 

Hope this helps you!! 

 Pooja Yadav