function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BarracksBarracks 

Few Questions about Apex Programming and Flows

Hi All,

Can someone explain what's the difference between a Flow to an Interview?

Second question, where can I find the Flow's constructors documentation? I tried looking it up on the link below but didn't find it.
https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_flowinterview.htm?state=id

The reason that I that I'm asking is because I'm trying to instantiate a new flow but sfdc presents an error:
Error: Compile Error: Constructor not defined: [Flow.Interview.ReturnHelloWorld].<Constructor>() at line 5 column 50

Code:
global class TestHelloWorld2 implements Schedulable{

 global void execute(SchedulableContext sc) {
  Flow.Interview.ReturnHelloWorld helloWorldFlow = new Flow.Interview.ReturnHelloWorld();
  helloWorldFlow.start();
}

}

I read in other posts that I need to pass a Map object as a parameter for the constructor, but where can I find the offical document that says it?
NagendraNagendra (Salesforce Developers) 
Hi Barracks,

First and foremost sincerely regret the inconvenience for the delayed reply.

Even though you aren't passing a variable into your flow, you still need to pass an empty map into the constructor.  Try the following instead:
Flow.Interview.myFlow startFlow= new Flow.Interview.myFlow(new Map<String, Object>());

See the following post for a better example: 
http://andyinthecloud.com/2014/10/26/calling-flow-from-apex/

Please mark this post as the best answer if it helps.

May salesforce be with you.

Best Regards,
Nagendra.P