vtigervtigercrm

beforesave vs beforesave.modifiable


Please, can somebody explain me what's the difference between the events vtiger.entity.beforesave and vtiger.entity.beforesave.modifiable?

and with vtiger.entity.beforesave.final?

Thanks!


Solution

  • That's a great question first of all. Here I have shared my thoughts on the triggers usage in sequential order.

    1. vtiger.entity.beforesave.modifiable

    This trigger is not used by Vtiger anywhere but it's a pre-trigger of "vtiger.entity.beforesave". When you register this trigger, you will get $entityData with Old Record Object and allow you to modify the object which will be used on the next trigger. Register for another module to override the object. There is a change of object value that gets overridden by Vtiger registered triggers.

    1. vtiger.entity.beforesave

    Vtiger uses this event to get the Old Object, set some values for specific fields, and use that object for Audit tracking.

    1. vtiger.entity.beforesave.final

    This event is also not used by Vtiger but it's a post-event of "vtiger.entity.beforesave". You can override the object passed from the previous event. So in other words, you can override Vtiger's default behavior in this event before a record is saved.