I’ve made a custom module with a one to many relationship. I’m implementing a after_relationship_add logic hook were I would like to update a field with the sum of a integer field from all the related module. I can’t found how to get only the attribute of the related records. So far I can make the sum of all the records of the link module, but not the one that I’ve chose during the select in the subpanel on the detail view after a create.
here is what I’ve made :
public function totalSF($bean, $event, $arguments)
{
$relatedBeans = BeanFactory::getBean('ORD_Maintenance')->get_full_list();
foreach ($relatedBeans as $relatedBean) {
$bean->total_square_feet_c = $bean->total_square_feet_c + $relatedBean->square_feet;
}
}