How to use onchange client script in multi row variable set

Nikita Singh
Giga Expert

Hi,

I want to see i3 as cpu selected and "total estimation cost is 300" in total_estimated_cost column if i select the choice as i3 in CPU field.

I want to use onChange client script to do this.

Here i have made:

Record producer: Estimation RP

Mutli row variable set: Disc size

pls help

 

find_real_file.png

 

1 ACCEPTED SOLUTION

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Not quite understand your requirement of why to do this. Though it is possible to onLoad and also onChange outside the MRVS, to fill rows in the MRVS.

Look at example script below. Obviously, you have to change the variable names, mrvs name. Maybe you also have to do something with labels/values. Though basic script works (= tested).

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

	var rowObj = [];
	rowObj.push(
		{
			"actions": "",
			"mrvs_variable_1": g_form.getValue('name_of_variable_you_are_trying_push')
		}
	);

	g_form.setValue('name_of_your_mrvs', JSON.stringify(rowObj));

}

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

5 REPLIES 5

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Not quite understand your requirement of why to do this. Though it is possible to onLoad and also onChange outside the MRVS, to fill rows in the MRVS.

Look at example script below. Obviously, you have to change the variable names, mrvs name. Maybe you also have to do something with labels/values. Though basic script works (= tested).

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

	var rowObj = [];
	rowObj.push(
		{
			"actions": "",
			"mrvs_variable_1": g_form.getValue('name_of_variable_you_are_trying_push')
		}
	);

	g_form.setValue('name_of_your_mrvs', JSON.stringify(rowObj));

}

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi Mark,

This script is not working.

 

Hi Mark,

 

Can you please let me know how can i get a value and populate the value dynamically by using on-change script.

per Example in the below image : If Number is 123 the Cart should display yes.

find_real_file.png

Thanks,

Mahesh R

Hi there,

How is number generated in your example? Automatically, onLoad, onChange of a variable outside of the MRVS, manual?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark

---

LinkedIn

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn