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
Aaron Persich 9Aaron Persich 9 

Flow and visualforce page to redirect to finish record

Hello,
 
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

Controller
 
Public class ExtensionName {

    Public Flow.Interview.Create_POV_Opportunity myAutoFlow { get; set; }
    Public ExtensionName(ApexPages.standardController controller) {}
    
    Public String getmyID() {
        if (myAutoFlow==null)
            return '';
        Else
            return myAutoFlow.varNEWOppty;
        }
    Public PageReference getNextPage(){     
    PageReference p = new PageReference('/' + getmyID() );
    p.setRedirect(true);
    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}"/>
            </flow:interview>
    <apex:detail subject="{!Opportunity.Id}"/>
               
 
</apex:page>
 
 
I am not sure what I am missing.
 
Any help is much appreciated.
 
Thanks,
 
Aaron