convert synchronous...
 
Notifications
Clear all

[Solved] convert synchronous method to asynchronous in Apex

2 Posts
1 Users
0 Likes
514 Views
Posts: 192
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

How to convert a synchronous method to asynchronous in Salesforce?

1 Reply
Posts: 192
 CWL
Admin
Issue starter
(@cwl)
Member
Joined: 11 years ago

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);
}
Reply
Share: