The CreatorCon Call for Content is officially open! Get started here.

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

that's the reason i asked you for screenshot ,

 

anyway , that will also hide. can you paste the script which you have used till now. 

 

 

Here are screenshots of what I did:

variable sets:

find_real_file.png

 

First variable set (sm_variable_seta):

find_real_file.png

 

second variable set (it_to_its):

find_real_file.png

 

The client script (test client script), which is added to the first variable set (sm_variable_seta):

find_real_file.png

 

The record producer:

find_real_file.png

 

I follow these steps but the variable "another_vs" never disappears:

(1) Open record producer page.

(2) Enter this value in the one_vs field: "harsh".

(3) Change the value in one_vs to "abc".

(4) Change the value in one_vs back to "harsh".

(5) Fill the other fields.

(6) Click on Submit button

 

you are testing on portal, so you have to set UI type as ALL in your catalog client script.

Thanks. so I changed the UI Type to "All" and it worked. But as I told you, in my case the client script should be on a MRVS not a single row variable set so I created a new variable set and called it: mrvs and added the client script there as you can see in the following screenshots. I also disabled the previous client script.

find_real_file.png

find_real_file.png

find_real_file.png

Here are the steps that I follow:

(1) Open record producer

(2) Click on Add button

(3) A popup will open and then I'll set "mrvs_variable" to "harsh".

(4) Click on "Add" in the popup

 

Expected result: "coming inside if" alert should appear and the variable "another_vs" should disappear.

 

Actual result: "coming inside if" alert should appear but the variable "another_vs" does NOT disappear.

glad it helped,

it will also possible. 

 

sample code:

 

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

var ab = JSON.parse(g_form.getValue('apps_enable'));

for(var i = 0 ; i < ab.length; i++){

if(ab[i].set == 'No'){

alert('hey');

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

else{

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


}

 

}

 

Note: apps_enable is MRVs ( here "set " is column in MRVs, so you will add your column based on your have )  and "appss" will be your another variable set. 

 

 

If my answer helped you, kindly mark my answer as correct and helpful.