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

Setting the Finishlocation to the new Flow-created record

I am using a record detail custom button to refer to a Visualforce page which in turn launches a Flow. That Flow then creates a new record. I would like my Finishlocation to be that newly created record. As it is now, I am only able to make the Finishlocation an already created record (such as the record I was in when I pushed the button ; or some other record which is a lookup field on that record).

I am referring to a variable which has the newly created record's ID.

Here is the Visualforce page which the custom button refers to :
<apex:page StandardController="Vendor_Product__c" Extensions="New_ProductReview_With_Flow_Controller2">
<flow:interview interview="{!myflow}" name="New_Product_Review" finishlocation="{!finishlocation}"> 
<apex:param name="VarVendProdRecID" value="{!Vendor_Product__c.Id}"/>
<apex:param name="VarVendProfileID" value="{!Vendor_Product__c.Vendor__r.Id}"/>

Here is the controller : 
public class New_ProductReview_With_Flow_Controller2 {
     public Id recordId {get;set;}
    public flow.interview.New_Product_Review myflow {get;set;}

    public New_ProductReview_With_Flow_Controller2(ApexPages.StandardController stdController) {
        recordId = ApexPages.currentPage().getParameters().get('recordId');

    public String getendID() {        
        if (myflow !=null) return myflow.VarNewReviewRecID;
        else return 'home/home.jsp';

    public PageReference getFinishLocation() {        
        PageReference endlocation = new PageReference('/' + getendID());

        system.debug('VarNewReviewRecIDxxxx '+getendID()); 
        return endlocation;

VARNewReviewRecID is a null value in the above debug for some reason, even though it is the Variable populated with the Create Record element in the Flow and I can see it is populated when I look at the debug logs. It is an input/output variable so I would think I could refer to it from Apex.

Any ideas ?
See if this helps: