+ Start a Discussion
irlrobinsirlrobins 

Return variable to finishLocation?

Hey all,

 

Taking my first plunge into VisualFlow. I've bashed together a lil proof of concept and it's all working fine bar one thing.

 

What I'd like is that when the flow finishes, the user is taken to another VisualForce page. This Visualforce page is passed a parameter that has the value of a variable in the flow. This is how I'm currently trying to do it:

 

In the VF page:

<flow:interview name="Test_1" interview="{!myflow}" finishLocation="{!EndPage}"/>

 

In the controller for this page:

    public PageReference getEndPage() {
        PageReference pageRef = Page.EndOrder;
         String oid =myflow.vOrder;
         pageRef.getParameters().put('order', oid);   
            return pageRef;
    }

 

where vOrder is a variable set in the flow.

 

But when I try and load the VF page I get the following error:

System.FlowException: Interview not started

 

How can I get the variable value that I can pass as a parameter to the follow page?

 

Thanks

 

 

RajaramRajaram

Your controller should have 2 methods, one for getting the variable from the flow and another for the finishLocation.

 

Something like this:

 

public class myAutoInsuranceController {

public Flow.Interview.Auto_Insurance_Quote myAutoFlow { get; set; }

public String getmyID() {
if (myAutoFlow==null) return '';
else return myAutoFlow.vaLeadID;
}

public PageReference getNextPage(){
PageReference p = new PageReference('/' + getmyID() );
p.setRedirect(true);
return p;
}

}

 

So your VF page will look something like this:

<apex:page controller="myAutoInsuranceController">
<flow:interview name="Auto_Insurance_Quote" interview="{!myAutoFlow}" finishLocation="{!nextPage}"/>
</apex:page>

 

Hope this helps..

 

irlrobinsirlrobins

Ok thanks, I'll try this later

benderguybenderguy

Does this really work? I'm trying to accomplish this but it seems like, in your example, when you call nextPage(), the flow has completed, making myAutoFlow==null, and thus you won't actually get the variable you are looking for anymore. What is the best way to do this (or am I wrong)? How do you set things up so that you can have access to the Flow variable after the Flow is complete?

jpb@uhcjpb@uhc

Thank you so much @Rajaram for this sample code....i have been looking for a solution and this worked!!

oodood

Why I  did it not worked? It error occur "URL No Longer Exists".

Paul P.ax1322Paul P.ax1322

any idea how to wrtite a test class for this?