$hook_array['before_save'][] = Array(1, 'rollupsum_won_oppts', 'custom/modules/Opportunities/custom_hooks/rollupsum_won_oppts.php','rollupsum_won_oppts_class', 'rollupsum_won_oppts_method');
<?php
class rollupsum_won_oppts_class {
function rollupsum_won_oppts_method($bean, $event, $arguments) {
if ($bean->sales_status == 'Closed Won') {
$account = BeanFactory::getBean('Accounts',$bean->account_id);
$account->closed_opportunities_c = 0;
$account->load_relationship('opportunities');
foreach ($account->opportunities->getBeans() as $opportunity) {
if ($opportunity->sales_status == 'Closed Won') {
$account->closed_opportunities_c = $account->closed_opportunities_c + 1;
}
}
$account->save();
}
}
}
?>
Hello Patrick:
How are you? Do you know if this is fixed? There isn't any update on the bug...
Thanks.
Kind regards.
Nikol.
Hi Nikol,
Conditional rollup is possible in the product using the following function:
Function: rollupConditionalSum
Description: Returns the sum of the values of $field in records related by $link where $conditionField contains something from $conditionalValues.
Parameters: Relate $link, String $field, String $conditionField, List $conditionalValues
Return Type: Number
I hope this helps!
Hi Nikol,
Conditional rollup is possible in the product using the following function:
Function: rollupConditionalSum
Description: Returns the sum of the values of $field in records related by $link where $conditionField contains something from $conditionalValues.
Parameters: Relate $link, String $field, String $conditionField, List $conditionalValues
Return Type: Number
I hope this helps!
Patrick,
This is great. Can you share a simple example of using it? Say I have a related field called invoice and I only want a rollupsum of invoices that has a status of "Closed".