Updating calculations based on aggregations

I put the following fields in a table:
expense_amount (number)
cash_expense_amount

if
(
 payment_method == "Cash" ||
 type == "Cash deposit ||
 type == "Checks deposit"
)
{
return expense_amount
}

bank_expense_amount

if
(
 payment_method == "Check" 
)
{
return expense_amount
}

tot_cash_expense_amount, aggregate SUM(cash_expense_amount)
tot_bank_expense_amount, aggregate SUM(bank_expense_amount)
tot_expenses

return tot_cash_expense_amount +tot_bank_expense_amount;

If I put the form in List view and I perform a search, the aggregates field update correctly, but tot_expenses doesn’t. All the calcs are stored.
I also tried to put the fields in a Grand Summary, but I get the same behaviour…

Hai Riccardino,

I would really like to help you but often I ‘stop right after starting’. I am lazy and get really confused by all italian words since I don’t understand italian.

Would it be possible for you to do such posting in english so I (and maybe others) can concentrate on the issue…

But ok, does a controller.saveData() help you?

IT2BE:
Hai Riccardino,

I would really like to help you but often I ‘stop right after starting’. I am lazy and get really confused by all italian words since I don’t understand italian.

Would it be possible for you to do such posting in english so I (and maybe others) can concentrate on the issue…

You’re right. I didn’t think about translating because the calc field containing those formulas don’t seem to have problems. I’ll translate the previous message…

BTW: saving data doesn’t change the result.

Update: the calcs seem to update if a loop thru the records. It seems that even jumping to last record forces the update. Is this an expected behaviour?

this should work fine with the latest releases (8 and 9) so i don’t get how the calc still doesn’t recalculate itself. CAn you send me an example?