
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Sometimes you might want to hide a Service Catalog variable, for example, based on the customer's geographic location or on the item ordered. (You might, for example, want to hide the "cpu_speed" variable if customers order an Executive Desktop.) Using a Service Catalog UI policy to hide a task variable does not work as well as one might hope: the variable is hidden in some places but not others. Hide-and-seek with task variables has been a game enjoyed played between task variables and users on certain patches of Eureka.
When do Catalog task variables appear/disappear?
- Using the catalog client script, g_form.setDisplay works on the catalog item but does not hide the variable on the task
- Similarly, using a catalog UI policy works on the catalog item but it does not hide the variable on the task
- Using g_form.setVisible does not hide the variable on the catalog item or task
Workaround for disappearing catalog task variables
To work around this issue, create an onLoad catalog client script that does both setVisible and setDisplay.
Navigate to Service Catalog > Catalog Client Scripts.
Click New.
Set Type to onLoad.
Set Applies to Requested Items to true.
Set Applies to Catalog Task to true.
Within the function onLoad() in the script field, add the following two lines:
g_form.setVisible('variables.macro_name', false);
g_form.setDisplay('variable_sys_id', false);
where variable_sys_id is the sys_id of the variable of type 'Macro'
The variables should now remain hidden in all desired locations.
Related information
nataraj_066 got an answer to a query asking how to show a catalog item variable in one task and hide it on a different task
See the product documentation Add catalog item variables to a task topic
See the product documentation What are some of the available helper functions? topic for a list of g_form objects you can use in your scripts to simplify certain common programming tasks such as hiding or showing fields
- As well as the known error for hiding variables on a task in the catalog: ServiceNow KB: Using a Service Catalog UI Policy to hide a variable of type Macro in the Service Cat...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.