Get values from MRVS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 02:30 AM
Is there any way to get values from MRVS?
Specifically, I would like to have a record producer variable automatically populated with the result of a calculation based on the following MRVS values.
In the screenshot below, I want to multiply the "金額" and "課金単位数" and set the result of adding each to the "利用料金" variable.
In this screenshot, we see
In this screenshot, 500 x 1 + 600 x 2 = 1,700, so we need to set 1,700 to the "利用料金" variable.
Can I do it?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 02:48 AM
Hi,
Please check below links almost same issue is resolved there:
https://pathwayscg.com/accessing-multi-row-variable-sets-client-side-in-servicenow/
Thanks,
Anil Lande
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 03:04 AM
Hi
Can you try this:
function onSubmit() {
var count = 0;
var mrvsData = g_form.getValue("u_request_data"); //replace with mrvs internal name
var mrvsDatastr = JSON.parse(mrvsData);
for (var i = 0; i < mrvsDatastr.length; i++) {
count = count + parseInt(mrvsDatastr[i].u_data1) * parseInt(mrvsDatastr[i].u_data2); //map your variable names
}
g_form.setValue("total_value", count); //map variable name where you want to set
}
Tested in my PDI
Hope it helps
Thanks
Murthy
Murthy

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 11:15 PM
Unfortunately, this isn't possble unless a new widget is created.
There are events that will detect addition and modification of mrvs rows but there is no event to detect deletion of mrvs rows. So, deleting a row or selecting delete all can not be detected and the total will be wrong.
The only way without developing a new widget is to create a button on the main form that will update the total when it is pushed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2022 11:17 PM
Hi,
You can use this
var mrvs = current.variables.multirowvs;
var totalRows = mrvs.getRowCount();
var arr = [];
for (var i = 0; i < totalRows; i++) {
var value = mrvs.getRow(i).getCell(',mrvs_col').getCellDisplayValue();
arr.push(value.toString());
}
current.variables.mrvs_to_string = arr.toString();
Regards
Vaishnavi