0

I am attempting to add the following button to a Visualforce page, which is functioning as the override to the View of an object.

The button will call another VF page - which in turn will call a Flow. I know the code works because I've used the button when using the object in a Page Layout.

Here is the following code for both the VF page it will call, and the extension/controller code it will run :

VF page :

<apex:page StandardController="Vendor_Profile__c" Extensions="New_RelatedVendor_With_Flow_Controller">
<flow:interview interview="{!myflow}" name="New_Related_Vendor" finishlocation="{!finishlocation}"> 
<apex:param name="VarPrimeVendProfRecID" value="{!Vendor_Profile__c.Id}"/>
</flow:interview>
</apex:page>

Extension :

public class New_RelatedVendor_With_Flow_Controller {
    public New_RelatedVendor_With_Flow_Controller(ApexPages.StandardController controller) {
         }

public flow.interview.New_Related_Vendor myflow {get;set;}
    public New_RelatedVendor_With_Flow_Controller() {
    }    

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

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

Thank you for any help you can provide. I would really appreciate it.

1

You can add this as a CommandButton on the page and invoke the page onclick of it, passing the retURL as the current page url.

<apex:commandButton value="Detail Page" onclick="invokeNewPage();" />

<script>
function invokeNewPage(){
    //You can also pass additional parameters, as it was overriding view , pass object record ID

    var recordId = ; //put your record id here
    var currentURL = window.location.href;
    window.location.href= '{!URLFOR($Page.pageName)}?id='+recordId+'&retURL='+currentURL;

}
</script>

Hope this helps :)

3
  • Thank you very much for your help. However, I'm confused on how that code fits in with mine. Does that all need to get added to the VF page I am using ? I'm already collecting the current record's ID with a param in the VF page above, so I don't understand how yours fits into it all. I'm also using the finishlocation in that original VF page to come back to after the Flow runs.
    – Zoom_v
    Dec 4 '15 at 19:15
  • Yes you have to this code to your page where you want to display the page. Dec 5 '15 at 1:27
  • Do I really need the script to be added to a VF page if I've already got that code run by the VF page I'm referring to above ? That is the VF page being called by my detail custom button and it is already creating the variable which contains the current record's ID, along with the extension it's running. Can I not just use the proper commandbutton to place the button onto another VF page ? If so, what would be the proper commandbutton to do it ? You're showing one which says invokenewpage, but is that really necessary with the code I've already got going on btwn my VF page and extension ?
    – Zoom_v
    Dec 7 '15 at 17:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.