2

I am creating a new record using Screen/Create Record elements of a Flow. I am starting that Flow with a customized New button. I am now attempting to make the FinishLocation as the newly created record. Here is the VF page which I am referring to with the New button in order to kick off the Flow :

<apex:page standardcontroller="Vendor_Profile__c" Extensions="New_Vendor_With_Flow_Controller2">
<flow:interview interview="{!myFlow}" name="New_Vendor_Profile" finishlocation="{!finishlocation}"/>
</apex:page>

and the class which is the Extension is this :

public class New_Vendor_With_Flow_Controller2 {

    public New_Vendor_With_Flow_Controller2(ApexPages.StandardController controller) {

    }


public flow.interview.New_Vendor_Profile myflow {get;set;}

    public New_Vendor_With_Flow_Controller2() {
    }
    
    public String getendID() {
        
        if (myflow !=null) return myflow.VarRecordID;
        else return 'home/home.jsp';
        }
       
    public PageReference getFinishLocation() {
        System.debug('VarRecordID ########'+ myflow.VarRecordID); 
        PageReference endlocation = new PageReference('/' + getendID());
        return endlocation;
        }
}

I am attempting to use the VarRecordID variable which I set in the Create Record element in the Page Reference.

I don't think I need to set a FinishLocation in the VF page, do I ? If I set that it will only go to that spot at the end of the Flow. I don't think I can refer to the VarRecordID variable in the FinishLocation so I didn't set one. Anyone have any suggestions on this ?

1 Answer 1

1

Yes, you will need to set the finishLocation in the visualforce page, you will also need a screen after the record is created, this screen causes a refresh of the visualforce page which will then give the finishLocation access to the variable.

9
  • – thanks very much for your input. I have made some changes to the code, both on the VF page and the controller. Interesting enough I'm getting an error: “Invalid Page Redirection–the page you attempted to access has been blocked to a redirection to an outside website”. I don’t know how that’s happening. I’m wondering if anything has to do with the fact that I'm using my controller as an Extension of a standard controller instead of simply referring to it as the Controller in the VF page.I would do that, but then I don’t have the VF page as an option when customizing the New button.
    – Zoom_v
    Oct 16, 2015 at 18:20
  • @Zoom_v take a look at this q/a for a possible solution to that issue salesforce.stackexchange.com/questions/4041/…
    – Jenny B
    Oct 16, 2015 at 18:29
  • Thank you @Jenny -That was a great post.But I can't say I have any more of any of whether or not my problems are being caused by me using an Extnsion instead of a Custom Contrllr.They mention wizard-like behavior as one of the times a Custom would be necessary.That is what I'm doing here with the Screen element of a Flow.I don't know how to use a Custom in a VF page in a way which would allow me to reference it for a customized New button-like I do if I use a Standrd cntrller referring to the object.Do you know what I need to write into a Custom to make it available for a customized button?
    – Zoom_v
    Oct 16, 2015 at 19:21
  • @Zoom_v why do you need to use a controller? I would probably just change it to an extension.
    – Jenny B
    Oct 16, 2015 at 19:23
  • I don't understand what you mean. It is an extension already. I'm using a Standard Controller so the VF page will show up as an option when I am customizing the New button.
    – Zoom_v
    Oct 16, 2015 at 19:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .