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

If you have tried it and it worked with you, you would do me a great favor if you can add a screenshot.

If you haven't tried it yet, please try it to understand what type of problem I'm facing 🙂

here we go, i tried to hide it one variable set based on another variable set variable value on form. 

 

 

i am not sure what exactly have you done, first point, why are you doing it on onSubmit() ? why not on change ? 

 

screenshot for reference

 

find_real_file.png

 

first variable set variable. 

 

find_real_file.png

 

Second variable set variable

 

find_real_file.png

 

RP form,

 

find_real_file.png

 

 

function onSubmit() {
//Type appropriate comment here, and begin script below

if(g_form.getValue('one_vs') =='harsh'){
alert('coming inside if');

g_form.setDisplay('another_vs',false);
return false;
}

}

 

find_real_file.png

 

Hope it will help you. 

now let me know if you have any further questions on it. 

 

Note: This will even hide or show the variable sets based on the condition . 

Hi Harshvardhan,

Thanks for your effort and for trying to help.

I tried what you suggested but it didn't work. Can you please send me a screenshot of the client script.

There is important thing that I didn't clarify in the original post: the variable sets are multi-row variable sets.

here we go, tested for MRVs as well.  working fine. 

 

function onSubmit() {
//Type appropriate comment here, and begin script below

if(g_form.getValue('one_vs') =='harsh'){
alert('coming inside if');

g_form.setDisplay('appss',false);
return false;
}
else{
g_form.setDisplay('appss',true);

}

}

 

Note: "appss" is my MRVS internal name. 

 

screenshot for reference. 

 

find_real_file.png

 

 

 

 

Hi,

 

I don't really get your solution. How come your code runs on Submit but the variable set to which it is attached is single-row variable set?

Note: both my variable sets are MRVS