Conditionally Rendering Template Sections In Salesforce CPQ

Suppose there is a scenario in which you are generating a Quote Template and you need the template sections to be displayed based on certain condition. You can do this by using ‘Conditional Print Field’ field in Template Section object. It is a picklist field that stores API names of Quote object fields.

Scenario: There are 10 products that you provide. A user selects 3 products as Quote Line Items. And when the user generates the quote template, you want to add content related to the products that user selected and not for all 10 products.

Steps:-

  • Create a check box field for each product in Quote object.

    a#example1
  • Create custom settings that map product name with related field name.

    a#example1
  • Write trigger to check / uncheck check boxes conditionally.

    a#example1
  • Add API names of fields created in Quote object for each product in Conditional Print Field field in Template Section object.

    a#example1
  • Create Template Section records in Quote Template record related list for each product’s Template Content record. Also assign ‘Conditional Print Field’ field value to API name of product.

    a#example1
  • Go ahead and click on ‘Preview Document’ button and make sure to select correct Quote Template.