how to copy previous row variable to new row in multirow variable set when users click on add

Chaiatnya
Tera Contributor

HI,

We have a requirement on Multirow variable set, when ever user clicks on add it should copy previous row variable to new row.

Can some one suggest how to achieve this

1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

Hi Kri,

First you'll need an onLoad Catalog Client Script running on the Catalog Item itself, not within the MRVS.  Set the UI Type to All.

function onLoad() {
	if (this) {//we only need to do this for Service Portal
		//We need to make the g_form object for the parent item available from the MRVS window
		this.cat_g_form = g_form;
	}
}

Now within the MRVS we can create an onLoad Catalog Client Script within the MRVS, also with the UI Type = All.

function onLoad() {
	var mrvs = '';
	if (this) {//Service Portal method
		mrvs = this.cat_g_form.getValue('mrvs1');//internal name of your MRVS
	}
	else{//native UI method
		mrvs = parent.g_form.getValue('mrvs1');
	}
	if(mrvs.length > 2){//native UI returns [] for empty MRVS value
		var obj = JSON.parse(mrvs);
		g_form.setValue('test_1', obj[obj.length-1].test_1);//name of the first MRVS variable to autopopulate
		g_form.setValue('test_2', obj[obj.length-1].test_2);
	}
}

View solution in original post

8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

Hi Kri,

Are you using the native UI, Service Portal, or both?  Do you want to populate only one variable, or all variables in the new row with variable(s) from the previous row?  Do you want to always copy from the previous row, or always copy from the first row?

HI Brad,

using both, Native UI and service portal. all the variables to be copied to the new row, I wanted to copy values form previous row

Edxavier Robert
Mega Sage

Hi, can you provide screenshot or more info about to help you on this? 

Hi, Please see below. 

On catalog item, when user clicks Add, on Multirow variable set, the row1 value to be copied to row 2, and again is user click on add it should copy the row 2 value to ro3 and so on

find_real_file.png