I have a SugarCRM 6.5 application. I have to trigger an email using after_save hook when a record is created(not during update).
I know I can use the workflow. But I can't use the workflow for this scenario due to multiple reasons.
Now I need to know how to find if the record is just created or is it being updated from after_save hook file?
if(!empty($bean->id) && date('Y-m-d',strtotime($bean->date_enterd)) == date('Y-m-d')) {
This condition won't help. Any idea how I can find if the record is created but not updated from after_save hook?
I achieved this by doing the following.
if(!empty($bean->id) && ($bean->is_first_mail_sent== 'no')) {
Note: I am not showing this value in layout. So no one can edit this value manually.
This works perfectly for me. The condition will return false forever after the first after_save hook since I have updated the value.
I am accepting this as an answer now. I am happy to change it if anyone else has another better idea.