+ Start a Discussion
vleandrovleandro 

Calling a Flow from Apex Class/Trigger

Please bear with me as I'll admit coding is something I'm new at and trying to learn! 

I create a very simple Flow, called ReturnHelloWorld.  It's only job is to display a message (using the Screen element) that says "Hello World!".

I created the following Apex Class:
public class ReturnHelloWorld {

    Flow.Interview.ReturnHelloWorld helloWorldFlow {get; set;}

}
I then created the following Apex Trigger to call the Class:
 
trigger CallMyFlow on Case (after insert) {
	
    for (Case c  : trigger.New) {
        
        ReturnHelloWorld hello = new ReturnHelloWorld();
    }

}
When I create a Case and save it, the Flow is not launched.  Based on all the reading and research I've done so far, it seems that really the only way for this to work is to call the Apex Class from a Visualforce page.  I wanted to confirm and make sure my code is correct.

Thanks for your help!


 
Best Answer chosen by vleandro
Andy BoettcherAndy Boettcher
Flows with screens cannot be called via a Triggered action, they are only invocable via a VF page or button that calls the flow directly.

You can check out a blog post of mine to get some good coding examples as well!  https://techman97.wordpress.com/2013/10/18/flow-and-finishlocation/

All Answers

Andy BoettcherAndy Boettcher
Flows with screens cannot be called via a Triggered action, they are only invocable via a VF page or button that calls the flow directly.

You can check out a blog post of mine to get some good coding examples as well!  https://techman97.wordpress.com/2013/10/18/flow-and-finishlocation/
This was selected as the best answer
vleandrovleandro
Thanks!  That's what I thought.  Great to get confirmation.