Using variable sets in a Catalog Task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 01:38 PM
Has anyone been able to develop a way to create variable sets in a Catalog item, then in task, pull just that variable set?
So if I have 3 predefined tasks for 3 groups, I want to be able to quickly tell the system to show the variable set I create for that group's task, rather than removing all the variables, then adding in the needed ones one by one.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 02:59 PM
Hello Carl,
Sure. The first option I would recommend is to do via Catalog UI policy. Please refer below link on how to create a new Catalog UI policy. When you create a new record select "Applies to " drop-down value to variable set. Screenshot for reference.
On the form, there will be three checkboxes like applies to requested item, catalog task, item view which controls where this Catalog UI policy will be applied.
The second option is to do it via catalog client script. Here at script level you can hide the variable set as
Sample :
if() //Your logic
{
g_form.setDisplay('PASS VARIABLE SET NAME HERE',false); // To hide the variable set
}
Reference:
Service Catalog UI Policy - ServiceNow Wiki
Creating a Catalog Client Script - ServiceNow Wiki
I hope this helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 04:02 PM
Pradeep,
I am already aware of the first section, but that is for the entire life of the catalog item, not in individual tasks.
Will the second part you mentioned work in the script section of a Catalog Task core activity in a Workflow?
g_form.setDisplay('PASS VARIABLE SET NAME HERE',false); // To hide the variable set

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 04:49 PM
Hello Carl,
The script I mentioned above will not work in the script section of Catalog Task. It has to be client script at sc_task level. In either of the case via Catalog UI policy or client script it will work only if you have a unique way of identifying the catalog task For ex: A unique field which identifies task as TASK B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 05:29 PM
Pradeep,
I may not be explaining clearly enough. I am trying to create several unique variable sets all with unique names. I then want them to be visible on tasks only when I need them to be, not at the sc_task level, otherwise this will not work, and I might as well just choose all the fields one by one to be seen on the task or not. I am just trying to make the updates to the tasks easier for workflow purposes, as whenever you add a variable, you have to remember to go in and add it as a visible field. If I can script this to just show a variable set, it will make this process easier.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2017 03:01 PM
To learn platform, please refer below blog. I have shared few tips here
Learning ServiceNow from Scratch and Prepping for the Certification Exam