2

I am creating a method that will call multiple flows. However I am receiving the following error - Variable does not exist: Interview. I have tried using both static and non static to no avail. Below is my code.

public void runFlows(List<Accrue_FlowOrderMap> flowMaps) {
    for(Accrue_FlowOrderMap flow : flowMaps) {
        try {
            Map<String, Object> params = new Map<String, Object>();
            for(Accrue_FlowParams flowParam : flow.params) {
              params.put(flowParam.paramName, flowParam.paramValue);
            }
            Flow.Interview flowToRun = Flow.Interview.createInterview(flow.flowName, params);
            flowToRun.start();
        } catch (Exception e) {
            System.debug(e.getMessage());
        }
    }
}

1 Answer 1

5

This is because

Flow.Interview flowToRun = Flow.Interview.createInterview(flow.flowName, params);

Flow is interpreted by the apex compiler to be a reference to the loop variable flow !

for(Accrue_FlowOrderMap flow : flowMaps)  

and the loop variable flow does not have a property called Interview

change your method to be something like this:

public void runFlows(List<Accrue_FlowOrderMap> flowMaps) {
    for(Accrue_FlowOrderMap accrueFlow : flowMaps) {
        try {
            Map<String, Object> params = new Map<String, Object>();
            for(Accrue_FlowParams flowParam : accrueFlow.params) {
              params.put(flowParam.paramName, flowParam.paramValue);
            }
            Flow.Interview flowToRun = Flow.Interview.createInterview(accrueFlow.flowName, params);
            flowToRun.start();
        } catch (Exception e) {
            System.debug(e.getMessage());
        }
    }
} 
2
  • Thank you!! I would have over looked that!!! I was thinking it was case sensitive!! Commented Jul 6, 2021 at 16:43
  • 1
    apex is not case sensitive; however, Flow input/output variable names are case sensitive
    – cropredy
    Commented Jul 6, 2021 at 16:44

You must log in to answer this question.

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