Subject : To getting to and from email value in after_save logic hook in create new records through bean
In Email module we create after_save logic hook
in that try to get value email from and email to value not getting in create records of email in after_save logic hook
but on update records get value to and from value of email
I am sending logic hook code
function update_from_to($bean, $event, $arguments) {
$query = 'SELECT from_addr,to_addrs FROM emails_text WHERE email_id = ' . $GLOBALS['db']->quoted($bean->id);
$results = $GLOBALS['db']->query($query);
$emails = $GLOBALS['db']->fetchByAssoc($results);
$from_email_string = $emails['from_addr'];
$to_email_string = $emails['to_addrs'];
$pattern = '/([^<>]*[^>\/])/i';
$from_email = preg_split($pattern, $from_email_string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$to_email = preg_split($pattern, $to_email_string, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$bean->from_email_address_c = $from_email[1];
$bean->to_email_address_c = $to_email[1];
$bean->save();
}
Using above code i am achieve on record update only but not in create
Please help us regarding this issue