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:14 AM
doesnt this refer to the MRV name?
sc_multi_row_question_answer
i am using a Record Producer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:24 AM
No, this is the table where MRVS is being stored.
Also, replace "addSizeQuery" to "addEncodedQuery" in line number 3.
This should work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:27 AM
Thank you, i have updated this but still no value displaying for the totals
(function executeRule(current, previous /*null when async*/) {
var grMRVSAnswer = new GlideRecord('sc_multi_row_question_answer');
grMRVSAnswer.addEncodedQuery('parent_id=' + current.getUniqueValue() + '^item_option_new=85d39b5e1b6c6410548fea4abc4bcbac');
grMRVSAnswer._query();
var totalInt = 0;
while(grMRVSAnswer._next()) {
if(grMRVSAnswer.value != '') {
// var amountInt = grMRVSAnswer.value.replace(',', '.');
totalInt = parseFloat(totalInt) + parseFloat(amountInt);
}
}
current.variables.u_total = totalInt.toString();
current.update();
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2020 11:44 AM
Couple of points
1- Uncomment below
// var amountInt = grMRVSAnswer.value.replace(',', '.');
to
var amountInt = grMRVSAnswer.value;
2- Make sure the amount sys_id in below line
item_option_new=85d39b5e1b6c6410548fea4abc4bcbac

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2020 11:09 AM
Hi Peter,
Hope you are doing well, did you get a change to look at my reply ?
Please mark answer correct if this helps.