Getting the Sum of all values from an MRV
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 10:44 AM
Hello everyone
what i am trying to figure out is how to get the Sum total of all values entered in a MRV to be async on the form before submitting.
I am created an expense form for employees to fill out and would like to have their totals to be disabled before they submit their form.
I was able to figure out how to get the totals after submitted the form by added a Script on the Record Producer to total up all values:
However i am not able to make this work in a BR which i believe is the best way to do it.
This is a very basic screen but you will get the idea
Here what i have so far in my Business Rule but this is coming from another posting i saw:
My table for the Recorder Producer is called:
u_tester
Variables are:
u_name
u_total
MRV internal name is:
test
Variable inside of the MRV is:
amount

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:35 AM
So you dropped the idea of doing this before submitting, and are going for doing this after submitting. Correct?
Can you explain what you already debugged on the script. You are only mentioning id doesn't seem to work.
So what's not working?
Did you debug if the encoded query is valid?
Did you debug if the if condition is entered?
Or is the Business Rule not triggered at all?
Or debugged th contents of totalInt?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:06 AM
Use can use below onsubmit client script sample to calculate sum of MVRS
Update MVRS variable name in this client script
function onSubmit() {
var totalEstimatedAmount = parseFloat(g_form.getValue('total_estimated_amount_sgd'));
var jsonStr = g_form.getValue("book_details");
var objList = JSON.parse(jsonStr);
var calculatedAmount = 0;
for (var i = 0; i < objList.length; i++) {
calculatedAmount += parseFloat(objList[i].estimated_price_sgd);
}
calculatedAmount = calculatedAmount.toFixed(2);
}
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:16 AM
This is not what i would need. i was able to figure out how to get the totals after submitting the form but looking for the totals on the request form
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2021 07:40 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:11 AM
Hi,
Please replace line number 2 with below
grMRVSAnswer = new GlideRecord("sc_multi_row_question_answer");