Generate Quote PDF in Salesforce1

KK Ramamoorthy
my journey with salesforce1 platform
3 min readOct 29, 2016

From Winter ’17, Salesforce1 supports creation of quotes which is super awesome. However, you won’t be able to view quote PDFs yet. You won’t be able to generate a quote PDF, save it or email it to your contact, either. There a couple of ideas in the idea exchange for this and until this gets some product manager love, I thought, I will post a work around here. Yes, this involves custom development but I just posted a lightning component for viewing PDFs in Salesforce1, here. With this lightning component and some simple Apex/VF/Lightning Component fun, you should be able to provide this capability to users, fairly easily.

I posted a sample code as a starting point for you, here. A couple of things to note

  • Go ahead and install the PDF Viewer component first in your org
  • Then install the sample Quote PDF component using the ‘Deploy to Salesforce’ button
  • Once you deploy this to your org, you will see a custom meta data object named ‘S1QuotePDFSetting’. Change the page layout of this custom metadata type to include the ‘Value’ field. Once done, go to ‘Manage records’ and update the value field for label ‘Template ID’, to the template ID used by the quote object in your org.
  • Quote object doesn’t support quick actions yet. Which means, we can’t use lightning actions either. However, Salesforce1 does support custom VF buttons (phew!). Go ahead, create a custom button of type Visualforce on the quote object and attach the VF page ‘S1QuotePDF’ to it
  • Remember to place this button in the page layout. Since this is a custom button, it will also be visible in the full site. If you don’t want to use this in full site, you may want to update the VF page to check where the user is accessing it from (you can use the $User.UIThemeDisplayed global variable) and show a message that this is intended for Salesforce1, so back off!
  • The VF page also uses another lightning component ‘S1QuotePDFComponent’ using lightning out. This component helps you understand how to use the PDF Viewer lightning component to display a quote PDF that is generated on the fly in Salesforce1. It also enables you to save the generated PDF.
  • I haven’t implemented the email functionality because it is fairly straight forward and there is tonnes of sample code available in the inter webs for this, so feel free to implement it yourself
  • Also, I haven’t implemented the ability to view an existing quote document (PDF) but that is fairly straightforward considering the heavy lifting is already done by the PDF Viewer component. One approach would be for you to fetch all the entries from QuoteDocument object, display them as a list and when a user choose a particular document, use the PDF Viewer component to display the PDF

Try this out and let me now how it works for you!

Now, the fine print.. At the time of writing this blog, I am employed with Salesforce as an Architect. However, any code samples and declarative approach provided here are purely for experimental purposes and comes with no warranty or support. Matter of fact, all opinions and approach provided in this blog are purely my own and has nothing to do with my employer. It is assumed that you have the right Salesforce configuration and coding skills and will use the ideas presented here as you see fit, in your landscape. The primary purpose of this article is just to share the knowledge and my own experience. Nothing more, nothing less. Use this approach at your own risk

--

--

KK Ramamoorthy
my journey with salesforce1 platform

Digital Tinkerer @awscloud; Love tech; it pays my bills as well, gadgets lover, handyman! Opinions are mine, not necessarily that of my employer