- When a new case record is created or existing case record is updated in Salesforce, we need to send these details to an external system using REST API call.
- Sometimes updates happen on same record in a very short duration of time. Case status changed to 'In Progress' at 10AM and then Case status is changed to 'Closed' at 10:01AM.
- When updates are happening back to back, our external system is going out of sync. Because the callout from future method for the 10AM update is still in Queued status but future method callout for the 10:01AM update finished.
- This is resulting in external system first updating the Case status to 'Closed'(10:01AM update in Salesforce) and then re-opening(10AM update in Salesforce) the case.
- We have a trigger on
Caseobject and it calls a future method to make API call to external system.
Note: I have looked into Platform Events and it guarantees the order of events but our external system cannot subscribe to the channel. It can only receive REST API calls.
Any better design to solve this problem?