A List Data Source allows you to retrieve multiple related records from Salesforce and use them in your document. This is useful when you need to display repeating data, such as Opportunity Products, Quote Line Items, Contacts, or any other related records.
Unlike a Single Data Source, which returns one record, a List Data Source returns a collection of records that can be repeated in your document using Config Types such as TABLE_ROW or PARAGRAPH.
In this example, you’ll create a List Data Source that retrieves all Opportunity Products related to an Opportunity and displays each product’s name and quantity in a table.
To understand the complete process, read this article and/or watch the accompanying video tutorial below before configuring a List Data Source. The video demonstrates each step visually and complements the instructions below.
Setting Up #
Suppose you have an Opportunity and want your generated document to include a list of all products associated with it.
For each Opportunity Product, the document should display:
- Product Name
- Quantity
The table row will automatically repeat for every Opportunity Product found.
Create a List Data Source #
- Open PDF Butler and navigate to Data Sources.
- Click New.
- Provide a name for your Data Source.
Example: Opportunity Products - Change the Type to: List
Selecting List tells PDF Butler that the query will return multiple records instead of a single record. - Save the Data Source.
Build the SOQL Query #
- Open the newly created Data Source.
- Use the SOQL Builder to generate the query.
The SOQL Builder helps you create queries without manually writing SOQL. - Choose an object (for this example we will use: Opportunity Line Item (Opportunity Product))
This object contains the products associated with an Opportunity. - Select the fields you want to retrieve.
For this example: Opportunity Id, Product Name, Quantity
You can add additional fields as needed. - Configure the Filter to retrieve only the products belonging to the current Opportunity.
This ensures that only Opportunity Products related to the current Opportunity are returned. - Save the query.
Open the Doc Config #
- Open your Doc Config.
- Load the newly created List Data Source.
- The Data Source is now available for Config Types.
Create a Repeating Table Row #
Since the Data Source returns multiple records, the table row must repeat for each record.
- Create a Config Type of type: TABLE_ROW
- Select the Opportunity Products List Data Source.
This tells PDF Butler to repeat the row once for every Opportunity Product returned by the query. - Inside the repeating table row, create Config Types for each merge field.
- Create a merge field for the Product Name.
Data Source: Opportunity Products
Field: Product Name - Create another merge field for the Quantity.
Data Source: Opportunity Products
Field: Quantity
Formatting can be applied if required. - Save the Doc Config.
Generate the Document #
- Open an Opportunity record.
- Generate the document using your Doc Config.
PDF Butler will:
- Retrieve all Opportunity Products related to the Opportunity.
- Repeat the table row for every product.
- Populate the Product Name and Quantity merge fields.
- Generate the completed document.