Notifications
Clear all
Oct 29, 2021 12:02 pm
How to convert a synchronous method to asynchronous in Salesforce?
1 Reply
Oct 29, 2021 12:06 pm
One reason to use future methods instead of queueable is when your functionality is sometimes executed synchronously, and sometimes asynchronously. It’s much easier to refactor a method in this manner than converting to a queueable class. This is handy if you need to move part of your existing code to async execution. Then simply create a future method that wraps your synchronous method as below:
@future static void yourFutureMethod(List<String> params) { // call synchronous method yourSyncMethod(params); }