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.

Variable Set Catalog Client Scripts: can they work on variables outside the set?

tahnalos
Kilo Sage

We have an existing Variable set that has a Catalog Client Script which works with the variables inside the Variable Set.

 

On several of the variables outside the set in our Catalog Item, we would like the Catalog Client script to work on those variables (checks will be made so that if a particular catalog item is used, we can populate those variables).

 

Do we need any special notation in our script to identify variables not part of the set?

 

Thanks

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

There are two types of Variable Sets, and two answers.

 

If you are referring to a single row variable set:

BradBowman_0-1764112845084.png

you can use standard g_form methods to get, set, ... variables inside or outside of the variable set in a Catalog Client Script that applies to either the Catalog Item or Variable Set, as long as they are included on the request form/RITM/Catalog Task - whatever the script Applies on...

 

When working with a multi-row variable set:

BradBowman_1-1764113036720.png

In a Catalog Client Script that applies to the Variable Set, you can use g_service_catalog.parent.getValue to access variables outside of the MRVS, and there's a bit more complicated way to set the value of an outside variable.  In a Catalog Client Script that applies to the Catalog Item you can get the value of the entire MRVS as JSON then loop through it to get/set the value of variables in each or certain rows of the MRVS.

 

View solution in original post

3 REPLIES 3

palanikumar
Giga Sage
Giga Sage

Normally Catalog Client Script can access all the variables from the form. So it should work fine.

 

Thank you,
Palani

Brad Bowman
Kilo Patron
Kilo Patron

There are two types of Variable Sets, and two answers.

 

If you are referring to a single row variable set:

BradBowman_0-1764112845084.png

you can use standard g_form methods to get, set, ... variables inside or outside of the variable set in a Catalog Client Script that applies to either the Catalog Item or Variable Set, as long as they are included on the request form/RITM/Catalog Task - whatever the script Applies on...

 

When working with a multi-row variable set:

BradBowman_1-1764113036720.png

In a Catalog Client Script that applies to the Variable Set, you can use g_service_catalog.parent.getValue to access variables outside of the MRVS, and there's a bit more complicated way to set the value of an outside variable.  In a Catalog Client Script that applies to the Catalog Item you can get the value of the entire MRVS as JSON then loop through it to get/set the value of variables in each or certain rows of the MRVS.

 

Thank you, yes, we are using a multi-row variable set, so the info is what we are looking for.