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 access variable set values from another variable set

Mohammad1
Tera Contributor

Hello,

I have record producer with 2 variable sets. I need to decide whether to show the second variable set based on the value that is entered in the first variable set. I assume that a UI Policy or a client script should solve this issue, however, it seems that accessing variables from another variable set is not a straight-forward task. Please let me know if you have tried something like this before.

Note: Both variable sets are multi-row variable set.

Thanks,

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

Use the onSubmit client script on catalog item level. 

 

Limitation MRVs

 

Note:

  • Catalog UI policies and catalog client scripts defined at the item level are not applicable for variables in a multi-row variable set. Only those catalog UI policies and catalog client scripts defined within the multi-row variable set are applicable for variables in the multi-row variable set.

 

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

View solution in original post

23 REPLIES 23

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Mohammad,

you can use catalog client script on that 1st variable set; check the value of variable from 1st variable set and based on that show/hide the variable from 2nd variable set

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

Thanks for trying to help. Can you please provide me with more details because I already tried your solution but it didn't work.

Hi Mohammad,

Can you share the script here?

Regards

Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

I have 2 variable sets: vs1 and vs2. vs1 consists of 1 variable called my_variable. If the value of my_variable is "A", I want to show vs2.

I created a client script with the following properties:

Applies to: A Variable Set

Type: Submit

Variable set: vs1

Script:

function onSubmit() {
	var value = g_form.getValue("my_variable");
	
	if (value == "A") {
		alert("value is A");
		g_form.setDisplay("vs2", true);
	}	
}