+ Start a Discussion
Aaron Persich 9Aaron Persich 9 

Flow and visualforce page to redirect to finish record

I am building a custom button with a flow and a visualforce on the opportunity object.  When the button is selected, the flow will create a new opportunity record.  I would like the finish screen to be on the newly created opportunity.  I have been doing some research and have asked the cloud for help.  I was told I need to create a custom controller which I have.  I think I have built everything correct but it is not working.  I might have something to do with my variables in my flow.  This is what I am working with.
Flow variables:
Record Lookup:  varOpportunityID
Record Create (Store new Opp info):  varNEWOppty
User-added image

User-added image

User-added image

Public class ExtensionName {

    Public Flow.Interview.Create_POV_Opportunity myAutoFlow { get; set; }
    Public ExtensionName(ApexPages.standardController controller) {}
    Public String getmyID() {
        if (myAutoFlow==null)
            return '';
            return myAutoFlow.varNEWOppty;
    Public PageReference getNextPage(){     
    PageReference p = new PageReference('/' + getmyID() );
    return p;

VisualForce Page
<apex:page standardController="Opportunity" extensions="ExtensionName" Showchat="False" showheader="True" standardStylesheets="True">
        <flow:interview name="Create_POV_Opportunity" interview="{!myAutoFlow}"  finishLocation="{!nextPage}">
                <apex:param name="varOpportunityID" value="{!Opportunity.Id}"/>
    <apex:detail subject="{!Opportunity.Id}"/>
I am not sure what I am missing.
Any help is much appreciated.