Skip to main content
Join the Agentforce Hackathon on Nov. 18-19 to compete for a $20,000 Grand Prize. Sign up now. Terms apply.

Structure a Customized Quote Template

Learning Objectives

After completing this unit, you’ll be able to:

  • Create template content that includes tables and text.
  • Merge data from the quote and related records into template content.
  • Assemble a quote template using template sections.
  • Describe how HTML contributes to template content.

The Building Blocks of Templates

The basic quote template you created in the last unit does a decent job of sharing quote details with the customer in a consistent manner. However, it has some significant limitations. For example, you can’t change the structure of the document. The layout is always the same, and it lacks parts of a typical proposal such as a cover page. Most businesses want more control over the structure of their proposal documents. Thankfully Salesforce CPQ gives admins the tools to create customized templates for such proposals.

The key to customized templates is what’s called Template Content. Think of a template content record as a piece of the puzzle that assembles into a complete proposal. For example, you might need template content that displays contact information for your customer and sales rep. A sample of that content might look like this.

Portion of proposal showing a two-column table with addresses and phone numbers.

As an admin you create many pieces of template content, building up a library to choose from. Then, you use pieces of template content to construct a customized quote template that displays piece after piece in a generated proposal.

Create Content with an HTML Editor

Your Salesforce CPQ-enabled org comes preloaded with some template content, but let’s create your own personalized content to display contact information. You start by navigating to the Template Content tab.

  1. In the navigation bar, click Template Content.
  2. Click New.
  3. Choose HTML as the type of content.
    Later you learn what the other types of content are used for.
  4. Click Continue.
  5. For Content Name, enter AW Contact Details.
    OK, now you’re ready to create the content, which is a combination of tables, static text, and merge fields.
  6. Click the Table icon (Table icon.).
  7. For Rows, enter 2.
  8. Click OK.
  9. In the top-left cell, enter Prepared For.
    This automatically resizes the column, but when you type in the next cell it’ll resize back to normal.
  10. In the top-right cell, enter Prepared By.
  11. Copy this code using the Copy button, then paste the contents in the bottom-left cell:
    {!quote.SBQQ__BillingName__c}
    {!primaryContact.Name}
    {!primaryContact.Email}
    {!primaryContact.Phone}
  12. Copy this code using the Copy button, then paste the contents in the bottom-right cell:
    {!template.SBQQ__CompanyName__c}
    {!salesRep.Name}
    {!salesRep.Email}
    {!template.SBQQ__CompanyPhone__c}
  13. Click Save.

Your content should look like this.

Table with two columns and two rows with text in each cell.

The stuff you just pasted was a bunch of merge fields that CPQ will replace with actual data from a given quote when the proposal is generated. Merge fields are always formatted to describe the source of data along with a field. For example, {!quote.SBQQ__BillingName__c} points to the quote as the source of data, and SBQQ__BillingName__c as the field to insert. The source always begins with an exclamation point, a period separates source and field, and everything is wrapped in curly brackets.

There are five sources you can draw from.

Source
Content
Example Merge Field
Output

!quote

The quote record itself.

{!quote.SBQQ__ExpirationDate__c}

7/24/2021

!primaryContact

The contact record that’s referenced in the quote’s Primary Contact lookup.

{!primaryContact.Title}

SVP, Operations

!salesRep

The user record that’s referenced in the quote’s Sales Rep lookup.

{!salesRep.Phone}

(312) 555-1212

!template

The quote template record selected when previewing or generating a proposal.

{!template.SBQQ__CompanySlogan__c}

Always Winning!

!document

The quote document record created by CPQ when generating a proposal.

{!document.SBQQ__Version__c}

2

It’s not possible to directly insert data from another source, such as the opportunity. If you need to show data from a related object, you must first create a formula field on the quote, and set it up to return the value of the field you’re interested in. Then, use the !quote source to merge the formula field into the proposal. Yep, the !quote source can draw from custom fields, and so can !template. The !primaryContact and !salesRep sources can’t, and are limited to the fields listed in this help article.

Add Styling to HTML

If you followed the steps above, you now have a workable piece of template content. However, in its current state it’s going to look a little boring. Basically black and white, with no borders or shading.

Contact Details table from the proposal document.

Before we associate your new template content with your quote template, let’s give your contact details some style, literally, using HTML styling tags. A few simple changes to the HTML will make the table look much better. You start by navigating to the template content record.

  1. While on the AW Contact Details record, click Edit.
  2. Click Source.
    You can make all sorts of tweaks to the HTML to give your content exactly the look you want, even if the GUI editor doesn’t have a button for it. To simplify things, we give you code that includes all of the styling.
  3. Replace the entire contents of the Markup window with the following code.
    <table border="1" cellpadding="1" cellspacing="1" style="width:500px;">
      <tbody>
        <tr>
          <td style="width: 35%; padding: 3px; background-color: #{!template.SBQQ__ShadingColor__c};">Prepared For</td>
          <td style="width: 35%; padding: 3px; background-color: #{!template.SBQQ__ShadingColor__c};">Prepared By</td>
        </tr>
        <tr>
          <td style="padding: 3px; border: solid black;">
            {!quote.SBQQ__BillingName__c}<br />
            {!primaryContact.Name}<br />
            {!primaryContact.Email}<br />
            {!primaryContact.Phone}
          </td>
          <td style="padding: 3px; border: solid black;">
            {!template.SBQQ__CompanyName__c}<br />
            {!salesRep.Name}<br />
            {!salesRep.Email}<br />
            {!template.SBQQ__CompanyPhone__c}
          </td>
        </tr>
      </tbody>
    </table>
  4. Click Save.

The new code includes a few nice changes.

  • Column widths are 35% each, making the table span only part way across the page.
  • Padding is set to three pixels so that text is pushed a little ways from the borders.
  • Borders are now solid and black.
  • The background color of the cells in the first row is set to {!template.SBQQ__ShadingColor__c}. Using a merge field will pull the hex code from the quote template record instead of relying on a hard-coded value. That way, one change at the template level will affect your content too.

Add Template Content to a Template

OK, you have a beautiful piece of template content, but the question still remains: How does CPQ know which pieces of template content to use for your proposal, and in what order? The answer is Template Section records.

Template sections are related to a quote template, each pointing to a piece of template content.

Object relationship diagram of quote template record with template section and template content.

Each section has a Display Order field used to sequence the template content from top to bottom. You can also tell CPQ to insert page breaks before or after a section. By using template sections with template content, you build your quote template piece by piece. Let’s add a template section to your quote template. You start by navigating to the quote template.

  1. In the navigation bar, click Quote Templates.
  2. Click AW Proposal.
  3. Click the Related tab.
  4. In the Sections related list, click New.
  5. For Section Name, enter Contact Details.
  6. For Content, find and select AW Contact Details.
  7. For Display Order, enter 10.
    We recommend that you order template sections using intervals of 10. That way, if you need to add a section between 10 and 20, you can number it 15.
  8. Click Save.

That’s the bare minimum you need to supply for a template section, but know that you can also adjust the Top Margin and Bottom Margin fields if you need to add space (in inches) between each section. Also, you can force a page break before and/or after the template section by setting the Page Break field. Later you learn what some of the other fields do too.

For now, let’s test the quote template using the same pre-made quote from the last unit.

  1. In the navigation bar, click Quotes.
  2. Click Q-00053.
  3. Click Preview Document.
  4. Click Preview.

Surprise! Your contact details are at the top of the document, but nothing else appears! The moment you add a template section to your quote template, it tells CPQ that you don’t want to use the standard structure of the basic proposal. You are now responsible for building the rest of the template. It’s not as hard as it sounds, and over the next few units you’ll add to your quote template until you have something even better than what you started with.

Finally, keep in mind that you can reuse template content on different quote templates. The AW Contact Details content will work just as well on a simplified proposal template as it will for a fully-fledged statement of work template. Later if you update the template content, all quote templates that use it will be updated at once.

In the next unit you learn other ways to use HTML template content, and how to make content appear only under certain conditions.

Resources

Share your Trailhead feedback over on Salesforce Help.

We'd love to hear about your experience with Trailhead - you can now access the new feedback form anytime from the Salesforce Help site.

Learn More Continue to Share Feedback