function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
GailGail 

finishlocation to return to original record

I call a flow from a hyperlink formula field on a Lead that looks like this:

HYPERLINK("/apex/ExploratoryCall?varLeadID="& Id , "Qualify" , "_self")

 My VF page looks like:

<apex:page standardController="Lead">
    <
    <flow:interview name="LogExploratoryCall" finishLocation="{URLFOR('/{!Lead.Id}')}"/>
    <apex:param name="varLeadID" value="{!Lead.Id}"/>
    <apex:param name="varLeadType" value="{!Lead.Type__c}"/>
    <apex:param name="varSectorInterest" value="{!Lead.Sector_Interest__c}"/>
</apex:page>

 I have tried various configurations for the URLFOR finishLocation such as using varLeadID, $Action.Lead.View, Lead.ID, etc. all to no avail. The above has me the closest, finishing with the following error:

Invalid Page Redirection
The page you attempted to access has been blocked due to a redirection to an outside website or an improperly coded link or button. Please contact your salesforce.com Administrator for assistance. 

Click here to return to the previous page.

 I've gone through the boards and various web posts but cannot see how to pass the Lead ID into the URLFOR. Should I use something instead of URLFOR? Do I really need a custom controller for this? I'm hoping to keep it simple and not require that. 

 

Any assistance greatly appreciated. 

 

Gail

DarrellDDarrellD

You can do it with a Controller extension like the below.  This will enable the landing page to be whatever ID is passed back to the VF page, even if it was newly created within the Flow so long as you assign it to the variable.  I found the solution in another post here by Rajaram. He's the Flow Lead with SF.

http://boards.developerforce.com/t5/Visual-Workflow/Flow-Finish-Location-in-VF-Page-Include-Field-Value/m-p/503303#M791

 

VF Page

<!-- Calls Flow and passes variables -->
<flow:interview name="AddressSearch" buttonLocation="bottom" finishLocation="{!FinishPage}">
<apex:param name="vaentrypoint" value="EnterNewAddressType"/>
<apex:param name="vafacilityid" value="{!Address_Type__c.Facility__c}"/>
<apex:param name="vaproviderid" value="{!Address_Type__c.Provider__c}"/>
<apex:param name="vaaddresstypeid" value="1"/>
</flow:interview>

 

Controller Extension

public class FlowFinishControllerExtension {

//Standard object type for controller extension
private final Address_Type__c addrtype;

public flowFinishControllerExtension(ApexPages.StandardController stdController) {
this.addrtype = (Address_Type__c)stdController.getRecord();
}

//Instance of flow
public Flow.Interview.AddressTypeAssign AddrTypeFlow {get; set;}

public String getaddresstypeID() {
String flowVariable;
if (AddrTypeFlow==null) return 'Home';
else flowVariable = (String) AddrTypeFlow.getVariableValue('vaaddresstypeid');
return flowVariable;
}

public PageReference getFinishPage(){

PageReference p = new PageReference('/home/home.jsp');
p.setRedirect(true);
return p;
}

}

RDM1961RDM1961

Great tip. Worked perfectly!  Any chance anyone has a test class for this?

 

Rick