- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 01:06 AM
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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 05:29 AM
@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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 01:26 AM
@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?
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 03:35 AM - edited 01-12-2023 03:36 AM
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 03:55 AM
@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.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-12-2023 04:26 AM
@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?