How can I identify in an after_save hook if a record is being created or edited?

I am working on a logic that depending on whether the action is editing, a task must be performed. Likewise, if are creating a record.

What is the way to identify if a record has been created or updated in an after_save hook?

Thanks in advance

The easiest way is to check the $bean->fetched_row variable if it is empty the record is new if it has an array with values in it the record is being edited

2 Likes