File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed
Server-Side Components/Business Rules/Find MRVS Total Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change 1+ ( function executeRule ( current , previous /*null when async*/ ) {
2+
3+ // --- Configuration ---
4+ var VARIABLE_NAME_TO_POPULATE_WITH_SUM = 'total_estimate' ; // Add the name of your variable where total should be saved
5+ var MRVS_INTERNAL_NAME = 'item_details' ; // Add the internal name of your multi-row variable set
6+ var MRVS_VARIABLE_NAME_TO_SUM = 'quoted_price' ; // Add the variable name that contains the value to be added for each row
7+
8+ // -- Don't change below --
9+ var mrvs = current . variables [ MRVS_INTERNAL_NAME ] ;
10+
11+ var total_value = 0 ;
12+
13+ // The mrvs variable is already a JSON string, so we need to parse it
14+ var mrvsRows = JSON . parse ( mrvs ) ;
15+
16+ // Loop through the parsed array of rows
17+ for ( var i = 0 ; i < mrvsRows . length ; i ++ ) {
18+ var row = mrvsRows [ i ] ;
19+ var line_price = parseFloat ( row [ MRVS_VARIABLE_NAME_TO_SUM ] ) || 0 ;
20+ total_value += line_price ;
21+ }
22+
23+
24+ current . variables [ VARIABLE_NAME_TO_POPULATE_WITH_SUM ] = total_value . toFixed ( 2 ) ;
25+
26+
27+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments