Title basically explains my question, I need to make a button that retrieves the Quote Object from one page and then send it to another VisualForce page that is rendered as a pdf and allows a user to print out all the info. Any idea as to how I would create this button and how i would allow it to send the data from one page to the other?

1 Answer 1


I would use the button to grab a quote object from the page, grab the ID of the quote in the action method, return a pagereference going to the second page while passing the ID in the query string.

return new PageReference('/apex/mypdfpage?id='+myQuote.ID);

then on the myPDF page, extract the quote details using SOQL and render accordingly :)

  • This is really helpful, but I just have two questions: 1.) would the button be a javascript button and 2.) I know how to use a query but i'm not sure how to search for a button that was clicked
    – Mike Stomp
    Commented Jun 12, 2015 at 15:49
  • Would you rather go for a javascript approach or the non-javascript approach? :)
    – dotmiko
    Commented Jun 12, 2015 at 16:11
  • whatever way is most efficient :)
    – Mike Stomp
    Commented Jun 12, 2015 at 16:12
  • Get the Quote ID of the object that you want to get displayed on your pdf page, lets say its going to be myQuote.ID. Create a pagereference that returns "return new PageReference('/apex/mypdfpage?id='+myQuote.ID);" - lets call the method public PageReference pdfMe() place pdfMe() in the apex:buttoncommand that you have. <apex:commandButton action="{!pdfMe}" /> and there you go!
    – dotmiko
    Commented Jun 12, 2015 at 16:54
  • if I have a preexisting page would it be PageReference myPDF = Page.(PDFQuoteTemplate+?id=quote.id); or am i off? If you would like to see me code for anything i can include it
    – Mike Stomp
    Commented Jun 12, 2015 at 17:12

You must log in to answer this question.

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