Skip to main content
2 réponses
  1. 29 mai 2023, 13:00
    Hello Shivesh ,

    Yes, it is possible to call an autolaunched flow from asynchronous Apex in Salesforce. Autolaunched flows can be invoked using the Flow.Interview class in Apex.

    To call an autolaunched flow asynchronously, you can use the Queueable Apex interface. The following steps outline the process:

    Create a new Apex class that implements the Queueable interface. This interface allows you to perform asynchronous processing in Salesforce.

    public class MyQueueableClass implements Queueable {

        public void execute(QueueableContext context) {

            // Call the autolaunched flow using Flow.Interview class

            Flow.Interview myFlow = new Flow.Interview.My_Autolaunched_Flow();

            myFlow.start(); // Start the flow

            

            // Perform any additional processing or logic after the flow is called

            // ...

        }

    }

    In your existing Apex code or trigger, enqueue an instance of your Queueable class to execute it asynchronously.

    MyQueueableClass myQueueable = new MyQueueableClass();

    System.enqueueJob(myQueueable);

    References -> https://help.salesforce.com/s/articleView?id=sf.flow_distribute_system_apex.htm&type=5 (https://help.salesforce.com/s/articleView?id=sf.flow_distribute_system_apex.htm&type=5)

    Help video -> https://www.youtube.com/watch?v=TxLPEW0fEqc

    Hope this helps !

    Thank you.