In response to Friday’s email regarding race conditions, a fellow reader suggested using platform events.
This is another great option, if you know how to use them.
If you don’t, here’s a quick synopsis:
When things happen in Salesforce, you may or may not be aware of it. Sometimes you need to know when something started or finished, such as a Salesforce-native background process.
For example, in the nonprofit world, when you create a contact, a household account is automatically created. However it’s an asynchronous process from a managed package, so you cannot create a contact in one step, and then simply get the newly created household in the next.
This scenario is a great candidate for a platform event. Once set up, you can execute additional automation once the household creation process completes.
Further, since platform events aren’t in real-time, you can use them in your automations to introduce timeouts and avoid race conditions.
The takeaway
If you don’t already use them, take a moment to learn about platform events. They may help you one day.