Bean Meeting on Logic Hook

Hi, there,
I created a Logic Hook where to create a new empty Meeting. When saving the Call an error is generated.
I bring back the code of the hook:

class AfterSaveCallLogicHook
     {
         function openMeeting($bean, $event, $arguments)
         {
           if($bean->status=='Meeting'){
             //ottengo l'id della lead associata alla chiamata
             /*$rel="leads";

             $bean->load_relationship($rel);
             $lead_assoc_id=$bean->$rel->get()[0];
*/
             // creo uno nuovo meeting
             $meetingBean=BeanFactory::getBean('Meetings');
             $meetingBean->name="Nuovo appuntamento3";
             $meetingBean->description="Nuovo appuntamento scaturito da chiamata";
             $meetingBean->save();

             
             echo "<pre>";
             var_dump($meetingBean);
             echo "</pre>";


           }
         }
     }

I tried the same code in an Entrypoint and it works.
I report the entry point code:


$meetingBean=BeanFactory::getBean('Meetings');
$meetingBean->name="Nuovo appuntamento2";
$meetingBean->description="Nuovo appuntamento scaturito da chiamata";
$meetingBean->save();

I report the error of suitecrm.log :

Mon Aug 26 17:49:13 2019 [20300][1][FATAL] SugarPHPMailer encountered an error: Invalid address:  (to): 

Which logic hook it is , before save or after save?

The class name seems to indicate it’s “after save” hook.

I suggest adding more fields, namely all the fields that are “required” when creating a meeting from the UI.

That’s right, it’s an “after save” hook.
I also thought it was a problem related to passing all the required fields… but I do not understand why the same ocode put in file for Entrypoint works ?

Checking the apache errors I found that the problem was on the dates, I passed the start and end dates and the script worked. For those interested I report the portion of code to create a meeting from a hook:

$meetingBean=BeanFactory::getBean('Meetings');
             $meetingBean->name="Nuovo appuntamento4";
             $meetingBean->description="Nuovo appuntamento scaturito da chiamata";
             $meetingBean->date_start='2019-08-28 13:00:00';
             $meetingBean->date_start='2019-08-28 14:00:00';
             $meetingBean->assigned_user_id=$bean->assigned_user_id;
             $meetingBean->created_by=$bean->assigned_user_id;
             $meetingBean->parent_type='Leads';
             $meetingBean->parent_id=$lead_assoc_id;
             $meetingBean->save();