I have two custom plugins, both doing different things but following the same pattern:
listen for a LEAD_POST_SAVE event
Check to see what fields have been updated
If certain fields are updated, then do some stuff and update the contact
The problem I have is that if Plugin A and Plugin B both get triggered for the same contact update, Plugin A will write to the record and when Plugin B runs it only sees the changes that Plugin A made, not the changes that triggered the subscribed event in the first place.
Is this intended behavior or do you think it warrants a GitHub issue?
Is there a way to get the changes from the LEAD_POST_SAVE event itself instead of calling $lead->getChanges() on the Lead object passed from the event so they can’t be messed with by other plugins?
This was exactly what was needed to make this work!
For anyone else’s benefit, I had modeled my plugins from the Clearbit plugin as a starting point, and it uses the LEAD_POST_SAVE event then fires saveEntity, so I assumed that was a good way to do it, but that actually messes up any other plugin looking to detect the changes to the lead after that. By moving both my plugins to LEAD_PRE_SAVE and not persisting/saving the changes in the subscriber, they both just work!
I may submit a PR moving the Clearbit plugin to LEAD_PRE_SAVE too. We don’t actually use the Clearbit plugin, but if we did, it would be part of the problem.