How to copy the variable values from one MRVS to another MRVS using client side scripting on the catalog form

Pravalika1
Tera Contributor

Hi Experts,

we got a requirement to fetch the values from one multirow variable set to another multirow variable set as soon as we enter the values in first multi row variable set.....

below is the script I tried:

function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == 'yes') {
//fetch the values from mrvs1 - fundnumber_and_client_information

// var fundNumber;
// var mchRegion = g_form.getValue('ehorizon_mch_owning_region');
// var cid = g_form.getValue('ehorizon_client_id');
// alert('client id:' + cid);
// var multiRowVariableSet = JSON.parse(current.variables.MRVS_name);
var mrvs = this.variables.fundnumber_and_client_information;
var rowCount = mrvs.getRowCount();
for (var i = 0; i < rowCount; i++) {
var row = mrvs.getRow(i);
alert('i value' + i);
}
// updating values in second mrvs2 -add_alternate_pricing_basis
var obj = (g_form.getValue('add_alternate_pricing_basis').length != 0) ? JSON.parse(g_form.getValue('add_alternate_pricing_basis')) : [];

obj.push({
//apb_select_fund_number: fundNumber,
apb_mch_owning_region: mchRegion,
apb_client_id: cid,
});
g_form.setValue('add_alternate_pricing_basis', JSON.stringify(obj));
}
}

 

Thank you,

Pravalika

3 REPLIES 3

Community Alums
Not applicable

Hi Pravalika,

This link should help you :https://community.servicenow.com/community?id=community_question&sys_id=9b4d5a84dbc1cc14d82ffb243996...

Mark my answer correct & Helpful, if Applicable.

Thanks,
Sandeep

Pravalika1
Tera Contributor

Thank you Sandeep for the quick response.

But, Seems like it is not working.

maroon_byte
Mega Sage

You cannot auto add row in 2nd MRVS as soon as you enter the values in 1st mrvs. You will need to have a widget button (for portal) a checkbox (for native portal) between 1st and 2nd mrvs to initiate copy down. See if below helps:

https://community.servicenow.com/community?id=community_question&sys_id=22f45a36dbfd8150019ac223059619e4&view_source=searchResult

 

Regards,

Sharad