You need to sign in to do that
Don't have an account?
Zoom_V
How can I add this Detail Page Button to a Visualforce page?
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 :
Extension :
Thank you for any help you can provide.
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.
MyExtension.cls
Page
You will want to update line 6 of the extension to point to your VF page and you'll also want to update 11 of the Page to change the name of the button. You will also want to update the class name of the extension to something more meaningful than myExtension
All Answers
and then in your controller do
You could also use apex:commandLink and then write custom CSS to make it styled like a button.
But I have never needed to put a custom button on a VF page before, and this is confusing because it has to use that small VF page just to call my Flow along with assigning the parent record ID to a variable to use in the Flow.
So I don't know how to properly put that button code of the VF and the controller you have into the ones I have.
Can you help me with that ?
Thank you so much.
MyExtension.cls
Page
You will want to update line 6 of the extension to point to your VF page and you'll also want to update 11 of the Page to change the name of the button. You will also want to update the class name of the extension to something more meaningful than myExtension
pcon - Thank you so much on this. That was so helpful. I've got the button working in the VF page now, and it is in turn referring to another page (the one in my original post) - which as you can see is also using another extension. I am mainly using that other page and extension for the sake of not only launching the flow, but also collecting the current record's ID with the param (to be used in the Flow) and setting the finishlocation of the Flow as well.
My problem is that my param/ID method isn't working. I'm guessing the best way to handle this would be to combine the VF pages (and Extensions) into one, but I'm not sure if that would work. This is where I was really losing it earlier, because I had a feeling they should be combined. Do you know how to do that ?
Thanks again. I really appreciate it.
pcon - Thank you for your response. The button will properly launch the other little VF page (which in turn launches the flow) but the param in that VF page is not producing the ID of the record which is open when the button is being pushed.
You're correct in that it is the ID in the URL at the time the button is pushed, but I am gathering it by referring to the actual ID of the record.
(the entire page is in my original post)
If the custom button is used in a Page Layout it will properly get the ID and save it to the variable. But it's not doing that when the button is put into this VF page.
I'm guessing it's because I'm essentially going from one VF page (the one with the button) - and then the button launches that other page which THEN tries gathering the record ID as it launches the Flow. Maybe it's because the ID can't be gathered from a VF page launched in the back-end like that ? Any ideas on that ?
I don't understand what you mean with by this : "If you visit your page with the flow embedded directly and provide the URL...." ... ?
Thanks for all of your help.