Visual Workflow – Controlling Finish Location for a Flow

My organization has a custom button on the Opportunity which calls a Flow to create the Opportunity. The code for the button is as follows:

/flow/Close_Opportunity_w_Handoff?OpportunityID={!Opportunity.Id}&UserTitle={!$User.Title}

We are now getting ready to implement Opportunity Products and we would like to have the end point for the flow above to be the add products page from the newly created Opportunity. Can anyone tell me how to accomplish this? I am very new to flows and this is one that was created by someone before me. Thanks for any help!

VF Page:

<apex:page standardController="Opportunity" tabStyle="Opportunity">
    <flow:interview name="Create_Opportunity_w_Parent_Fixed" finishLocation="/p/opp/SelectSearch?addTo={!opportunity.Id}&retURL=%2F{!opportunity.Id}"/>
</apex:page>

Controller:

public class OpptyFlowController {

  public Flow.Interview.Create_Opportunity_w_Parent_Fixed OppFlow { get; set; }

    public String getOppID() {
      if (OppFlow==null) return '';
      else return OppFlow.OpptyID;
    }

  public PageReference getOID(){
    PageReference p = new PageReference('/p/opp/SelectSearch?addTo=' + getOppID() + '&retURL=%2F' + getOppID();
    p.setRedirect(true);
  return p;
  }

}

Best Answer

In this situation I normally have the flow embedded in a VisualForce page, which may sound a bit intimidating if you haven't used one before but it's literally just a few lines.

Basically you create a very simple page like the below. This would send the user to another VF page:

<apex:page>
    <flow:interview name="MyUniqueFlow" finishLocation="{!$Page.MyUniquePage}"/>
</apex:page>

This to a particular non VF page:

<apex:page>
    <flow:interview name="MyUniqueFlow" finishLocation="{!URLFOR('/home/home.jsp')}"/>
</apex:page>

You will need to set the standard controller of the VF page available so that the button is available.

Some helpful links: https://help.salesforce.com/HTViewHelpDoc?id=vpm_admin_onfinish.htm&language=en_US http://www.salesforce.com/docs/developer/pages/Content/pages_flows_finishlocation.htm

Related Topic