AnsweredAssumed Answered

How to do a rollup sum in a logic hook?

Question asked by bryce@baymountaincapital.com on Jul 9, 2015
Latest reply on Jul 20, 2015 by bryce@baymountaincapital.com
I am trying to do a simple roll-up sum.  I created a custom module called Loans and each individual Loan has a field called Note Current Balance.  I want the field called Test Currency Field to be the sum of all Note Current Balances.

I think my logic is on the right track but I think the foreach loop is not structured the right way.  Please help!  Thanks!

$loan_bean = BeanFactory::getBean('Loans',$bean->loan_id);  $bean->test_currency_field_c = 0;  foreach ($loan_bean->getBeans() as $loan_bean) {  $note_current_balance = $loan_bean->note_current_balance_c;  $bean->test_currency_field_c = $bean->test_currency_field_c + $note_current_balance;  }

Outcomes