Total in Form Tool - GROOVE 3.1

M

Marc Dimmick

I am trying to get a totalling happening in the view. I have a workspace
which I got from the rapid soloution which shows the totalling column but I
am unable to get it totalling. Any ideas?

--

Regards
Marc Dimmick

"The best way to predict the future is to create it" - Dr.Peter F. Drucker
 
E

Evan Venn

An example is shown below:

I have created in this example groups of fields, I treat the fields like
this so I can created (and update) read-only subtotals - and, then the total
for the form.

I use events to call the routines to create the subtotals - a form correctly
designed like this needs though with respect to field naming convention.
Looking at the code today, I would use parameters to optimise the code but
this would not aid understanding the code example.

Evan Venn


// Code example, change field names!!!!!


// Sub group 1
function OutcomeAssigneeJobCosts_OnChange() {
AddSubGroup1();
}

function AddSubGroup1() {
var newsubtotal = TotalGroupOfFields( cOutcomeAssigneeJobCosts_Field )
SetHTMLFieldValueAsNumber( cOutcomeAssigneeJobCostsSubTotal_Field ,
newsubtotal);
AddSubTotals();
}

// end Sub Group 1

// Sub Group 2
function OutcomeAssigneeJobParkingCosts_OnChange() {
AddSubGroup2();
}

function OutcomeAssigneeJobTravelCosts_OnChange() {
AddSubGroup2();
}

function OutcomeAssigneeJobTravelOtherCosts_OnChange() {
AddSubGroup2();
}

function AddSubGroup2() {
var newsubtotal = TotalGroupOfFields( cOutcomeAssigneeJobParkingCosts_Field,
cOutcomeAssigneeJobTravelCosts_Field,
cOutcomeAssigneeJobTravelOtherCosts_Field )
SetHTMLFieldValueAsNumber( cOutcomeAssigneeJobTravelSubTotal_Field ,
newsubtotal);
AddSubTotals();
}

// End Sub Group 2

// Sub Group3

function OutcomeOtherJobCosts1_OnChange() {
AddSubGroup3();
}

function OutcomeOtherJobCosts2_OnChange() {
AddSubGroup3();
}

function AddSubGroup3() {
var newsubtotal = TotalGroupOfFields( cOutcomeOtherJobCosts1_Field,
cOutcomeOtherJobCosts2_Field );
SetHTMLFieldValueAsNumber( cOutcomeOtherJobCostsSubTotal_Field ,
newsubtotal);
AddSubTotals();
}

// end of Group3

// Now total the subtotals

function AddSubTotals() {
var newsubtotal = TotalGroupOfFields( cOutcomeAssigneeJobCostsSubTotal_Field,
cOutcomeAssigneeJobTravelSubTotal_Field,
cOutcomeOtherJobCostsSubTotal_Field);
SetHTMLFieldValueAsNumber( cOutcomeJobCostsTotalOnTab_Field , newsubtotal);

SetHTMLFieldValueAsNumber( cOutcomeTotalBeforeTax_Field , newsubtotal);
// calculate tax
var CalculatedTax = newsubtotal * GetHTMLFieldValueAsNumber(
cOutComeTaxValue_Field);
SetHTMLFieldValueAsNumber( cOutComeCalculatedTax_Field , CalculatedTax )
SetHTMLFieldValueAsNumber( cOutcomeTotalIncludingTax_Field , newsubtotal +
CalculatedTax )
}


// All the maths stuff
function TotalGroupOfFields() {
try {
var returnvalue = 0
if (arguments.length > 0) {
for (i=0; i<arguments.length; i++) {
var currentvalue = GetHTMLFieldValueAsNumber( arguments ) ;
returnvalue = returnvalue + currentvalue;
}
}

}
catch ( err ){
ShowError (err);
}
return returnvalue;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top