Hello friends, today we are going to discuss Run Flow Asynchronously In Salesforce. We added asynchronous paths that run in the background and don’t delay the execution of your original triggered transaction. Use an asynchronous path to execute a long-running operation, such as a callout to an external web service or any operation that you want to run on its own time. You can also use an asynchronous path to avoid the mixed DML error.
Also, check this: Scheduled Paths Flow In Salesforce
Key Highlights :
- We can avoid mixed DML errors in flow.
- We can invoke callout after DML.
- Used to break the transaction.
- We can’t define a time for an asynchronous path to run as you can for a scheduled path. And in situations when system resources are unavailable, the execution of an asynchronous path will be delayed.
- Both asynchronous and scheduled paths are subject to the same asynchronous per-transaction Apex limits.
- Only available for After trigger Flow.
- Checked the checkbox of Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed.
Process :
Here we will create a Trigger flow which we call when after the user record is created. We will create a contact record after that because, without the use of an Asynchronously path, we will get mix DML error. We use the Asynchronously path for this.
Step 1: First of all we will create a trigger flow. Navigate to Setup > Flows > click New Flow. Create a Record-triggered flow. Select Record-triggered Flow and then click Next.
Step 2: Here we will setup up object and Entry Conditions. Also, Select Action and related records at the Bottom. Also Checked the checkbox of Include a Run Asynchronously path to access an external system after the original transaction for the triggering record is successfully committed.
Step 3: Now in Asysn Path we add Create record element and set up the contact record fields for creating the contact record.
2 comments
Once the Asynchronous action is completed, how can the flow be notified (callback) to then move to another step that depends on the completion of the Asynchronous step?
Create a subflow.