3

I have two Autolaunched flows in my org with the same API Name. The API Name is Account_Record_Criteria_Evaluator. One flow belongs to a managed package and another exists in my org. I want to call both flows from my Apex code using below scripts.

(Org Flow) Calling below code works:

String recordId = '001XXXXXX';
String objectApiName = 'Account';
Map<String, Object> inputs = new Map<String, Object>();
inputs.put('recordId', recordId);
inputs.put('objectApiName', objectApiName);
Flow.Interview criteriaFlow = Flow.Interview.createInterview('Account_Record_Criteria_Evaluator', inputs);
criteriaFlow.start();

(Managed Package Flow) Calling below code gives System.TypeExceptions:

String recordId = '001XXXXXX';
String objectApiName = 'Account';
Map<String, Object> inputs = new Map<String, Object>();
inputs.put('recordId', recordId);
inputs.put('objectApiName', objectApiName);
Flow.Interview criteriaFlow = Flow.Interview.createInterview('pcp__Account_Record_Criteria_Evaluator', inputs);
criteriaFlow.start();

Since both flows has same API names but different namespace, how can I call these Autolaunched flows from Apex code.

1 Answer 1

3

There's a separate method for calling with a namespace.

Have you tried:

Flow.Interview criteriaFlow = Flow.Interview.createInterview('pcp', 'Account_Record_Criteria_Evaluator', inputs);

See also: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/flow_interview_class.htm#apex_Flow_Interview_createInterview

Where the method signature is:

public static Flow.Interview createInterview(String namespace, String flowName, Map<String,ANY> inputVariables)
1
  • Thank you @Nick C. I am now asking myself why didn't I read the documentation. Commented May 7 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .