Question for confirmation: Callout from Trigger using Platform Events

after-triggerasynchronouscalloutfutureplatform-event

After a record is updated in Salesforce, i need to perform a callout to synchronize data to an External System.

Ideally, i would like to do this kind of synchronously, however it doesn't seem to be achievable.
I read this document from Salesforce, where it is said that we can perform callouts after publishing Platform Event messages. However, there is a note saying: "This feature doesn't change the way you make Apex callouts from Apex triggers, which require the @future(callout=true) annotation."

My questions is more for confirmation: Is there a chance that in a Trigger i publish a platform event, and after the event is published to perform a callout to the external system? I suppose no, but i ask more for confirmation.

From my understanding, we should use @future methods, however it also needs handling concerning the Order of execution (update the record now and in 2 seconds – callouts could be performed in a different sequence, since they are asynchronous.

Best Answer

Platform Event Triggers also can't make callouts, so you'd still need a Future or Queueable method. Note that asynchronous methods are still called in order of being queued, so you don't really need to worry about the "ordering problem."

Related Topic