MRVS issue

Keerthika2
Tera Contributor

Query:

There are two MRVS,where by adding one row, should automatically add row in second MRVS. Also there is lot of restriction imposed , not supporting DOM. 

Approach 1 :Failed

I tried to pass whole JSON from first MRVS to other MRVS through setvalue but did not work. Not able to access second mrvs within first MRVS.

Approach 2 :Failed 

I tried to create the temporary variable outside the MRVS on the catalog item but even that did not work.

Please let us the know the better solution

1 REPLY 1

Tanushree Maiti
Mega Patron

Hi @Keerthika2 

 

Create an onChange Catalog Client Script

  • Variable set: Select the first MRVS(mrvs_one).
  • Variable name: Choose a variable inside the first MRVS that triggers the change .
  • Type: onChange

 

function onChange(control, oldValue, newValue, isLoading)

{

if (isLoading || newValue === '')

{

return;

}

var mrvs1 = g_form.getValue('mrvs_one');

 

var mrvs1 = g_form.getValue('mrvs_one');

var mrvs2 = JSON.parse(g_form.getValue('mrvs_two'));

var newRow = mrvs1[mrvs1.length - 1];

var rowToPush = { 'variable_a_mrvs2': newRow.variable_a_mrvs1,

                                      'variable_b_mrvs2': newRow.variable_b_mrvs1

mrvs2.push(rowToPush);

g_form.setValue('mrvs_two', JSON.stringify(mrvs2));

}

 

 

refer: Auto add row to multi row variable set 

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: