How to autopopulate variable value of multi row variable set in another variable (which is not mrvs)

shivani39
Tera Expert

Hi All,

 

Can someone help me with the script, basically I want to auto populate a variable value which is single line text in a multi row variable set. This value should auto populate in another variable(which is not mrvs, but a normal multiline text).

Multi row variable set has number of rows, like if users add 5 rows, 5 times we will fill that single line text and all those 5 values should autopopulate in that multi line text variable.

 

Please help.

 

Thanks

Shivani

1 ACCEPTED SOLUTION

@jaheerhattiwale But from the above code its not reading all the rows. The field is inside each row, you can't see from this image. I am pasting another image for that field.

shivani39_0-1673530152062.png

 

View solution in original post

8 REPLIES 8

jaheerhattiwale
Mega Sage
Mega Sage

@shivani39 We can read the mvrs and add the data to multiline text field. But we must need a trigger point.

Like on submit we can get the data from mvrs and add it to multiline text field. Is this ok?

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi @jaheerhattiwale ,

 

Yes the trigger point comes when we select "Is SQL need new account" = Yes, then we see this multi line text  variable (NEW SQ ACCOUNT) where we have to get the value from the above mrvs row(selected package). Will that be ok instead of submission of the form?

 

shivani39_0-1673523345638.png

 

@shivani39 Create a onchange client script on "Is New SQL Account Needed" and add following code.

 

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

var mvrsValue = g_form.getValue("<INTERNAL NAME OF VARIABLE SET>");
mvrsValue = JSON.parse(mvrsValue);

var multilineTextValue = [];
for(var i=0; i<mvrsValue.length; i++){
multilineTextValue.push(mvrsValue[i].<VARIABLE SET VARIABLE NAME>);
}

g_form.setValue("<MULTI LINE TEXT VARIABLE NAME>", multilineTextValue.toString());
}

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@jaheerhattiwale It is working only for one row, the minute I add second row it is taking the latest value and removing the first one. I gave two values refer the below image. So it should have populated as test, gloabl in the multi line text variable field. Can please help with giving multiple value?

 

shivani39_0-1673526345310.png