AnsweredAssumed Answered

Before_save logic hook for mass update

Question asked by Xabi Pico on May 14, 2018
Latest reply on May 15, 2018 by Xabi Pico

Hi,

 

I have a before_save logic hook for Calls module and work perfect. That's my code in /custom/modules/Calls/logic_hooks.php:

 

$hook_array['before_save'] = Array();

$hook_array['before_save'][] = Array(100, 'Before Save', 'custom/modules/Calls/BeforeSaveHook.php','BeforeSaveHook', 'beforeSave');

 

And this is the function:

 

class BeforeSaveHook {

   function beforeSave(&$bean, $event, $arguments) {

      if (($bean->fetched_row[‘status’] != 'Held' && $bean->status == 'Held')){          if($bean->parent_type == 'Contacts' && $bean->parent_id != ""){

               $contact = BeanFactory::getBean('Contacts', $bean->parent_id);

               $today = date('Y-m-d');

               $contact->harreman_data_c = $today;

                                 $contact->save();

                     }

               }

         }

}

 

 

This works well when update one Call, but when I need to update Calls with mass update method the logic_hook only work for one record. What is the correct way to use a before_save hook for mass update?

 

Thanks all,

 

Xabi

Outcomes