Based on Variable value Need to show/hide variables in Variable set(MRVS)

Saranya K
Tera Contributor

Hi all, 

 

I have  created select box variable  name Application Type with choice new, update and delete and also i have created  MRVS with 4 variables.

Based on the Application type i need to show variables in the Multi-row variable set

 

 

2 REPLIES 2

Ankur Bawiskar
Tera Patron
Tera Patron

@Saranya K 

so basically you want to show/hide variables within MRVS based on outside variable?

you can create onLoad catalog client script which applies on MRVS variable set and access the outside variable like this

var applicationType = g_service_catalog.parent.getValue("application_type");

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

mahemoodhus
Tera Contributor

Hi @Saranya K ,
Hope you are doing well!
You’ll use a Catalog Client Script to dynamically control the visibility of variables in the MRVS.
So here the code 

function onChange(control, oldValue, newValue) {
// Get the value of the select box
var applicationType = g_form.getValue('application_type'); // Replace with your select box variable name

// Show/Hide MRVS variables based on the Application Type
if (applicationType == 'new') {
g_form.setVisible('mrvs_var1', true); // Replace 'mrvs_var1' with the actual variable names in the MRVS
g_form.setVisible('mrvs_var2', false);
g_form.setVisible('mrvs_var3', false);
g_form.setVisible('mrvs_var4', false);
} else if (applicationType == 'update') {
g_form.setVisible('mrvs_var1', false);
g_form.setVisible('mrvs_var2', true);
g_form.setVisible('mrvs_var3', false);
g_form.setVisible('mrvs_var4', false);
} else if (applicationType == 'delete') {
g_form.setVisible('mrvs_var1', false);
g_form.setVisible('mrvs_var2', false);
g_form.setVisible('mrvs_var3', true);
g_form.setVisible('mrvs_var4', false);
}
}
Another way you can achieve this scenario, if you don't want to write a script, you can create multiple UI Policies as well as you can use Datalook-up as well