+ Start a Discussion
Scott SpilkerScott Spilker 

Redirecting flow to newly created record with visualforce and apex

I am trying to create a case record using a visual workflow that presents the user with only the required fields.  At the end, I'm trying to get the workflow to redirect the user the the created case.  I found this blog post which seems easy enough but it is failing.  Can someone help?

http://codefriar.com/2014/04/18/a-reusable-redirect-controller-for-visualflows/

My visualforce page is the following:  
 
<apex:page Controller="FlowRedirectController">
    <flow:interview name="RedirectFlow" interview="{!redirectTo}" finishLocation="{!finishLocation}" >
        <!-- This Parameter is *required!* -->
        <apex:param name="StartFlow" value="Data_Request_Flow" />
        <!-- 
        Any Params you need to pass into your flow.
        <apex:param name="CaseId" value="{!CaseId}"/> 
        -->
    </flow:interview>
</apex:page>

My Apex Class is the following: 
 
Public class FlowRedirectController{

   Public Flow.Interview.RedirectFlow redirectTo {get; set;}
    
   public FlowRedirectController() {
       Map<String, Object> forTestingPurposes = new Map<String, Object>();
       forTestingPurposes.put('vFinishLocation','codefriar.wordpress.com/');
       redirectTo = new Flow.Interview.RedirectFlow(forTestingPurposes);
   }

   Public PageReference getFinishLocation(){
       String finishLocation;
       if(redirectTo != null) {
           finishLocation = (string) redirectTo.getVariableValue('vFinishLocation');
       }
       PageReference send = new PageReference('/' + finishLocation);
       send.setRedirect(true);
       return send;
   }
}


My flow is called "Data_Request_Flow" and is Type=Flow.   

Whenever I navigate to the visualforce page, it errors out saying, "Interview not started 
An unexpected error has occurred. Your solution provider has been notified. (Flow)"
 
Sukesh Kumar 33Sukesh Kumar 33
Salesforce have broken the <flow:interview> component in the run up the Winter '14 release.
They are aware of this but we have not been given a resolution ETA yet.