The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Using variable sets in a Catalog Task

Carl Murray
Mega Expert

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.

9 REPLIES 9

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.


Screen Shot 2017-03-24 at 2.56.20 PM.png



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


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


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


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.


To learn platform, please refer below blog. I have shared few tips here


Learning ServiceNow from Scratch and Prepping for the Certification Exam