Skip to content

Instantly share code, notes, and snippets.

@cdcarter
Forked from noeticpenguin/ExampleVFFlowPage.html
Last active August 29, 2015 14:21
Show Gist options
  • Save cdcarter/55084cad6f84667e5736 to your computer and use it in GitHub Desktop.
Save cdcarter/55084cad6f84667e5736 to your computer and use it in GitHub Desktop.
<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}"/>
-->
</flow:interview>
</apex:page>
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;
}
}
@isTest
private class Test_FlowRedirectController{
static testmethod void SetVariablesTests() {
PageReference pageRef = Page.ExampleVFFlow;
Test.setCurrentPage(pageRef);
FlowRedirectController testCtrl = new FlowRedirectController();
System.assertEquals(testCtrl.getFinishLocation().getUrl(), '/codefriar.wordpress.com/');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment