Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Universal Redirect controller for VF Based Pages.
<apex:page Controller="FlowRedirectController">
<flow:interview name="RedirectFlow" interview="{!redirectTo}" finishLocation="{!finishLocation}" >
<!-- This Parameter is *required!* -->
<apex:param name="StartFlow" value="YOUR_FLOW_NAME_HERE" />
Any Params you need to pass into your flow.
<apex:param name="CaseId" value="{!CaseId}"/>
Public class FlowRedirectController{
Public Flow.Interview.RedirectFlow redirectTo {get; set;}
public FlowRedirectController() {
Map<String, Object> forTestingPurposes = new Map<String, Object>();
redirectTo = new Flow.Interview.RedirectFlow(forTestingPurposes);
Public PageReference getFinishLocation(){
String finishLocation;
if(redirectTo != null) {
finishLocation = (string) redirectTo.getVariableValue('vFinishLocation');
PageReference send = new PageReference('/' + finishLocation);
return send;
private class Test_FlowRedirectController{
static testmethod void SetVariablesTests() {
PageReference pageRef = Page.ExampleVFFlow;
FlowRedirectController testCtrl = new FlowRedirectController();
System.assertEquals(testCtrl.getFinishLocation().getUrl(), '/');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.