Getting the Sum of all values from an MRV

Peter Williams
Kilo Sage

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:

find_real_file.png

 

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 

find_real_file.png

Here what i have so far in my Business Rule but this is coming from another posting i saw:

find_real_file.png

 

find_real_file.png

 

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

18 REPLIES 18

doesnt this refer to the MRV name?

sc_multi_row_question_answer

 

i am using a Record Producer

No, this is the table where MRVS is being stored.

Also, replace "addSizeQuery" to "addEncodedQuery" in line number 3.

This should work

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);

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

Hi Peter,

Hope you are doing well, did you get a change to look at my reply ?

Please mark answer correct if this helps.