Pass a variable value from the main form variable to a multi-row variable set

Zane2277
Tera Contributor

Greetings, 

I have a catalog item with a select box and multi-row variable set. If a requestor selects a specific option in the dropdown for File Share, the customer needs a select box to be visible in the MRVS asking what type of access is needed. 

Zane2277_0-1688994087588.pngZane2277_1-1688994108884.png

My challenge is passing the value of the dropdown choice to the MRVS so that I can create a UI Policy to display the Type of Access dropdown only if that parent variable option is File Share. 

 

Is it possible to pass the value of the dropdown option to the MRVS so that I can only show the dropdown based upon the parent variable value? 

 

I am relatively new to scripting and have seen some examples of others passing the value in the native UI but am not sure how to pass this value for the service Portal. 

 

Any assistance would be appreciated. 

Thank you.

 

1 ACCEPTED SOLUTION

Brad Bowman
Mega Patron

Use an onLoad Catalog Client Script that applies to the MRVS instead.  Within this script, you can reference variable values on the parent form using g_service_catalog.parent.getValue('var_name')

https://developer.servicenow.com/dev.do#!/reference/api/rome/client/g_service_catalogClientAPI#g_ser... 

 

So if this variable is named v_resource_type, and the value you're testing against is 'file_share' (be sure to use the Value column, not Text in the choice list), and given that the variable will be displayed by default, your script would simply be:

if (g_service_catalog.parent.getValue('v_resource_type') != 'file_share') {
    g_form.setDisplay('v_access_type', false);
} 

 

View solution in original post

5 REPLIES 5

deekshithkd
Mega Contributor

Can someone help me in this situation, how to approach this 

I have a requirement here, where I have two fields, one is a  "select the group" field referencing to group table which is in the main form and another field called "user", referencing the user table which is inside the MRVS, and one more thing, every user in the user table has 2 records, for example, someone called James, he has two ids, with same name, like

James - GFRTY

James - A_GFRTY, 

This is for most of the users.

 

Now, if someone selects any group in the Group field, and if the selected group has "Zen" in the group name, then I need to write a reference qualifier to the user field inside the MRVS, like if the selected group has "Zen" in the group name, then I need to write a reference qualifier in the user field inside the MRVS, to show only the user names that has the ids with A_ and not the normal ids, for example, 

 

If the selected group name is "Integration zen support" or "MFA zen admins", then I need to show only the names with the ids that Starts with A_.