How to avoid the domino effect from Plugins?

Recently, we noticed that one of our plugins was behaving curiously. I hope the details below help you avoid some troubleshooting in future.

Scenario: The plugin was pretty simple – it retrieved 8 fields from the ‘Opportunity’ entity and based on a logic, updated 1 of them.

Issue: The logic worked well except for the fact that after this plugin ran, it triggered other workflows and plugins. After some investigation, we found that processes being triggered were those that are supposed to run on change of the other 7 fields. However, we weren’t updating the value for them.

Problem and Solution: When you retrieve and update an entity using a plugin, all attributes listed get updated. The simple fix is to have another call with only the attributes you intend to update. You can then use this retrieved entity to update the required fields without causing a crazy domino effect.

If you have any questions or if this article needs corrections, please leave a comment below. Thanks for stopping by!

Can't find what you're looking for? Leave a comment below and I promise to add it for you!

%d bloggers like this:

Like what you read? Read more!

Don't miss the action - subscribe and receive notifications of new posts by email.

Subscribe!