We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

MVRS

montoyb1
Tera Contributor

Hello, is there a way that I can do MVRS dynamically to change depending on the topic selected in a select box in a record producer

4 ACCEPTED SOLUTIONS

GlideFather
Tera Patron

Hi @montoyb1,

 

MRVS can be handled the same way as a simple variable. Catalog UI Policy and/or Catalog Client scripts, depending on the nature of what exactly you want to achieve.

 

In both there's "Applies to" field, select Variable set and associate with the desired (MR)VS to proceed:

GlideFather_0-1770976194552.png

 

_____
100 % GlideFather experience and 0 % generative AI

View solution in original post

yashkamde
Kilo Sage

Hello @montoyb1 ,

 

You can use the onChange client script for changing mrvs depending on the topic selected in a select box,

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

        if (newValue == 'true') {
	
	        var obj = JSON.parse(g_form.getValue('mrvs_1')); //get values from MRVS1
	        var nObj = []; //blank array
	
	        for (var i=0; i < obj.length; i++) { //iterate through obj
                var ft = obj[i].field_type;
		        var name = obj[i].name;
		        var noo = obj[i].number_of_options;
		
		        if (ft == 'check-box' || ft == 'drop-down') { //check the field_type
			        for (var i2=0; i2 < noo; i2++) { //repeat for the number of options required
				        nObj.push({
					        field_name: name //push field_name into an array
				        });
				        g_form.setValue('mrvs_2', JSON.stringify(nObj)); //set the values in MRVS2
			        }
		        }
	        }
	}
}

 

If my response helped mark as helpful and accept the solution.

View solution in original post

Ankur Bawiskar
Tera Patron

@montoyb1 

if you are saying you want to add/remove rows to/from MRVS based on other variable, then yes it's feasible.

You write client script on your select box variable and then form array of json objects and set that in MRVS

I have shared solution in below link, check that and enhance as per your requirement

How to populate Requestor Details in variables of MRVS?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

@montoyb1 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

4 REPLIES 4

GlideFather
Tera Patron

Hi @montoyb1,

 

MRVS can be handled the same way as a simple variable. Catalog UI Policy and/or Catalog Client scripts, depending on the nature of what exactly you want to achieve.

 

In both there's "Applies to" field, select Variable set and associate with the desired (MR)VS to proceed:

GlideFather_0-1770976194552.png

 

_____
100 % GlideFather experience and 0 % generative AI

yashkamde
Kilo Sage

Hello @montoyb1 ,

 

You can use the onChange client script for changing mrvs depending on the topic selected in a select box,

function onChange(control, oldValue, newValue, isLoading) {
	if (isLoading || newValue == '') {
		return;
	}

        if (newValue == 'true') {
	
	        var obj = JSON.parse(g_form.getValue('mrvs_1')); //get values from MRVS1
	        var nObj = []; //blank array
	
	        for (var i=0; i < obj.length; i++) { //iterate through obj
                var ft = obj[i].field_type;
		        var name = obj[i].name;
		        var noo = obj[i].number_of_options;
		
		        if (ft == 'check-box' || ft == 'drop-down') { //check the field_type
			        for (var i2=0; i2 < noo; i2++) { //repeat for the number of options required
				        nObj.push({
					        field_name: name //push field_name into an array
				        });
				        g_form.setValue('mrvs_2', JSON.stringify(nObj)); //set the values in MRVS2
			        }
		        }
	        }
	}
}

 

If my response helped mark as helpful and accept the solution.

Ankur Bawiskar
Tera Patron

@montoyb1 

if you are saying you want to add/remove rows to/from MRVS based on other variable, then yes it's feasible.

You write client script on your select box variable and then form array of json objects and set that in MRVS

I have shared solution in below link, check that and enhance as per your requirement

How to populate Requestor Details in variables of MRVS?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@montoyb1 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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