Getting Started with Process Builder – Part 97 (Now, Generating a Quote PDF is a breeze! Learn how!)

Getting Started with Process Builder – Part 97 (Now, Generating a Quote PDF is a breeze! Learn how!)

Last Updated on December 30, 2020 by Rakesh Gupta

The last thing you want your Sales teams to do is to get ensnared in manual – or procedural – activities; they are your horsepower, free them up to do what they do best – Sell! Does that mean activities – not directly related to selling – can be eschewed? Far from it! 

Let us have our cake and eat it too – think automation!!

Multiple research affirms the positive impact of automation on the bottom line! By leveraging automation, we can ensure that activities – not directly related to sales – get done without burdening your sales team. 

Let us take a simple use case – generating a quote PDF whenever a customer is ready to receive a formal proposal containing the most current pricing information and product quantities. To generate a quote pdf should not require salespeople to click a button! And, thanks to Process Builder, we can make that a reality!


After reading this blog, you’ll be able to: 

  • Understand what a Quote is
  • Use filters and conditions to design a process
  • Understand the Apex callout process in Process Builder

Business Use case

Martin Jones is a System Administrator at Gurukul on Cloud (GoC). He received a requirement to auto-generate a quote pdf whenever a quote gets created (only if Opportunity amount is greater than 0) so that salespeople can spend less time in Salesforce and more time selling.  

What is a Quote?

A quote is a detailed list – of products or services with prices, shipping and billing addresses, payment terms and taxes, etc. – that is sent by a seller to a prospective buyer. Quotes usually have different statuses (Draft, In Review, Presented, Approved, Rejected, or Cancelled) depending on the stage of the sales process.

As of Summer’20 release, salespeople had to manually generate a quote pdf by clicking on the Generate PDF button. We can do better than that as automation champions – let us automate this process. 

Automation Champion Approach (I-do):

Usually, with Salesforce, multiple approaches are available to solve a business requirement. Choose the ones that are simple, straight forward, and consume fewer resources. 

Similarly in this scenario, either use Apex trigger or a combination of Flow and Process Builder.

Let us solve this scenario using Process Builder and Apex – as this business case involves generating PDF out of a quote record. Before diving further, let me show you a diagram of a Process Flow at a high level. Please spend a few minutes to go through the following Flow diagram and understand it.

Screen Shot 2020-06-17 at 1.01.02 AM

Let’s begin building this automation process.

Guided Practice (We-do):

There are 6 steps to solve Martin’s business requirement using Process Builder. We must: 

  1. creating a custom label to store Quote Template Id
  2. Create Apex class & Test class
  3. Define process properties
  4. Define evaluation criteria
  5. Define process criteria
  6. Add action – call an Apex class

Step 1: Creating a Custom Label 

  1. Click Setup.
  2. In the User Interface, type Custome Labels.
  3. Clicks on the New Custom Label button.
  4. Enter Short Description the Name will auto-populate. 
  5. Now enter the Quote Template Id in the Value.
  6. Click Save

PB 96.1

Step 2: Create an Apex class and Text class   

  1. Click Setup.
  2. In the Quick Find box, type Apex Classes.
  3. Clicks on the New button.
  4. Copy code from GitHub and paste it into your Apex Class. 
  5. Click Save.

PB - 97.3.45

Repeat the above steps and click the Test class. You can get the code from my GitHub repo. 

Step 3: Define Process Properties

  1. Click Setup.
  2. In the Quick Find box, type Process Builder.
  3. Select Process Builder, then click New.
  4. Name the Process and click the Tab button. The API Name will populate. 
  5. As a best practice, always input a description
  6. The process starts when A record changes.
  7. Click Save.

PB 97.3

Step 4: Define Evaluation Criteria

  1. Click on the Add Object node to begin selecting the evaluation criteria.
  2. Select the Quote object from the dropdown list.
  3. Start the process only when a record is created.
  4. Click Save.

PB 97.4

Step 5: Define Process Criteria

  1. Click the Add Criteria node to begin defining the process criteria.
  2. Name the criteria.
  3. The criteria should execute actions when the conditions are met.
  4. Set Conditions
    1. Row 1:
      1. Field: Quote | Opportunity ID
      2. Operator: Is null
      3. Type: Boolean
      4. Value: False
    2. Row 2:
      1. Field: Quote | Opportunity | Amount
      2. Operator: Greater than
      3. Type: Currency
      4. Value: 0
  5. Select All of the conditions are met (AND)
  6. Click Save.

PB 97.5

Step 6: Add Action – Call Apex

  1. Below Immediate Actions, click Add Action.
  2. For Action Type, select Apex
  3. Name the action.
  4. Select the enerateQuotePdfDocument Apex class. 
  5. Set Field Values:
    1. Field: QuoteIds
    2. Type: Field Reference
    3. Value: [Quote].Id
  6. Click Save.

PB 97.6

Almost there! Once everything looks good, click the Activate button. Moving forward, a PDf for a quote will be automatically created whenever a new quote is created with status Draft

Note:- Before you activate your process, you will want to make sure that you have assigned data in the correct format because Process Builder obeys validation rules. If some fields are required by validation rules then, make sure you add those fields. Conversely, if some fields are required on the page layout, you can ignore those fields. 

It’s time to test this feature!

Next time, when a Sales rep creates a quote and associates it with Opportunity (obviously Opportunity amount must be greater than 0) then, the process builder will fire and auto-generate a quote pdf for it. 

Great! You are done! Feel free to modify it based on your business requirement. 

Formative Assessment:

I want to hear from you!  

What is one thing you learned from this post? How do you envision applying this new knowledge in the real world? 

Let me know by Tweeting me at @automationchamp, or find me on LinkedIn.

Author: - Rakesh Gupta
Technical Editor: - Munira Majmundar
Have feedback, suggestions for posts, or need more information about Salesforce online training offered by me? Say hello, and leave a message!

17 thoughts on “Getting Started with Process Builder – Part 97 (Now, Generating a Quote PDF is a breeze! Learn how!)

  1. HI , Team i need a solution for Custom Quote pdf generation.
    i am done the vf and apex class but button on PDF how to do, any idea.
    {save and email quote } && {save to quote} how to create these on PDF why because i an customizing total pdf.

  2. Hi there, I am using this and it has been working wonderfully, but I have had one issue when I updated the quote template to add some more details to the footer of the quote. For some reason when it is manually generated, the footer shows up blank. When I manually click to generate the PDF quote it shows up. Any thoughts on why this could be?

  3. I am calling this Apex from a screen flow that allows the user to input some relevant quote information before generating the quote and pdf. When I run the debug from the flow, it works wonderfully. When I run the flow from a lightning action, the pdf displays blank. I checked the debug logs for both instances and they’re practically identical so I can’t tell where it’s broken. Any thoughts?

  4. Hi Rakesh, I have an error on the test class. Error: Compile Error: Variable does not exist: RecordTypeId at line 25 column 12.
    I removed the “AND developerName = ‘Manufacturing'” as I don’t need it but still not working. Any idea why? I would also like to attach the PDF to a custom object instead of the opportunity. But let’s start to make it work 🙂

    1. If you are not using the RecordType in Opportunity, then remove all references. Like the following code:

      private class generateQuotePdfDocumentTest {

      static void setup() {

      Product2 product = new Product2();
      product.Name = 'Test Product ';
      product.ProductCode = '123';
      product.IsActive = true;
      insert product;

      PricebookEntry pbe = new PricebookEntry();
      pbe.Pricebook2Id = Test.getStandardPricebookId();
      pbe.Product2Id = product.Id;
      pbe.IsActive = true;
      pbe.UnitPrice = 10;
      insert pbe;

      Opportunity op = new Opportunity();
      op.Name = 'Test';
      op.Type = 'Value Proposition';
      op.Amount= 1200;
      op.CloseDate =;
      op.StageName = 'Created';

      insert op;

      Quote quote = new Quote();
      quote.OpportunityId = op.Id;
      quote.Name = 'TestQuote';
      quote.ExpirationDate =;
      quote.Status = 'Draft';
      quote.Pricebook2Id = Test.getStandardPricebookId();
      insert quote;

      QuoteLineItem qli = new QuoteLineItem();
      qli.QuoteId = quote.Id;
      qli.Quantity = 2;
      qli.PricebookEntryId = pbe.Id;
      qli.UnitPrice = 20;
      insert qli;

      static void generateQuotePdfTest() {

      Quote quote = [SELECT Id, Status FROM Quote LIMIT 1];

      quote.Status = 'Draft';
      update quote;


  5. Awesome stuff Rakesh! I found this article yesterday and gave it a try with Flow. I was able to repurpose it for our Quote Process and have the PDF generated automatically at the end of a guided screen flow.
    Just working on attaching the PDF and emailing it to the related contact now (also in Flow).
    One other thing, i’ve never written an APEX class and test class before, so quite happy that I was able to take yours and adjust it to my requirements.
    Thanks for the great content!

  6. I love that you have Conga and Docmotion as sponsors and yet chose to publish this kind of article, kuddos to you Sir !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.