---
title: PDF Butler – Fill KeyValue DataSources from Flow
description: "Before you begin, read this article to understand the configuration process. You can also watch the accompanying video tutorial for a visual walkthrough of each step. [PDF Butler - Fill KeyValue DataSources from Flow](https://www.youtube.com/embed/8PdRZQ1rdNo?feature=oembed)   ## PDF Butler supports **Key-Value…"
url: "https://pdfbutler.com/academy/pdf-butler-academy/pdf-butler-salesforce-automation/pdf-butler-fill-keyvalue-datasources-from-flow/"
updated: "2026-08-24"
category: PDF BUTLER SALESFORCE AUTOMATION
---

# PDF Butler – Fill KeyValue DataSources from Flow

Before you begin, read this article to understand the configuration process. You can also watch the accompanying video tutorial for a visual walkthrough of each step.

[PDF Butler - Fill KeyValue DataSources from Flow](https://www.youtube.com/embed/8PdRZQ1rdNo?feature=oembed)

 

##

PDF Butler supports **Key-Value Data Sources**, allowing you to populate data dynamically from a **Salesforce Flow** before generating a document.

This feature is useful when your document requires:

- Complex calculations
- Advanced validations
- Custom lookups
- Data assembled from multiple sources
- Information that is not easily retrieved through standard PDF Butler Data Sources

Previously, this type of functionality required Apex. With Key-Value Data Sources, you can now prepare and pass data directly from a Flow.

PDF Butler supports two types of Key-Value Data Sources:

- **Single Key-Value Data Source** – Passes a single record to PDF Butler.
- **List Key-Value Data Source** – Passes multiple records to PDF Butler.

The data is prepared inside the Flow and supplied to PDF Butler during document generation.

---

#### How It Works

Because Salesforce Flow actions cannot currently pass complex objects directly to Apex, the data must be formatted as **structured text**.

Each record is represented as a string following this format:

```
DataSourceIdentifier|Field1:Value1;Field2:Value2;Field3:Value3
```

PDF Butler parses this string and populates the configured Key-Value Data Source.

##### Understanding the Data Format

Each record consists of three parts:

```
DataSourceIdentifier
|
FieldName:Value
;
FieldName:Value
;
FieldName:Value
```

##### Components

| Component | Description |
| --- | --- |
| DataSourceIdentifier | Identifies the Key-Value Data Source that will receive the data. |
| Pipe ( | ) | Separates the Data Source identifier from the field values. |
| Colon ( : ) | Separates each field name from its value. |
| Semicolon ( ; ) | Separates multiple fields. |

Example:

```
CustomerDataSourceId|name:John Smith;city:Antwerp;street:Main Street
```

You can identify the target Data Source using either:

- **Salesforce Record ID**
- **Customer Data Source ID**

Although both are supported, using the **Customer Data Source ID** is recommended because it remains consistent across Sandbox and Production environments.

Salesforce Record IDs differ between environments, while Customer Data Source IDs remain unique across all orgs.

---

#### Creating a Single Key-Value Data Source

For a single record:

1. Create a **Text Collection Variable** in your Flow.
2. Create a Formula Resource that builds the structured string.
3. Add the formula output to the collection variable.
4. Pass the collection to the PDF Butler Flow Action.

Example:

```
CustomerDataSourceId|
name:John Smith;
city:Antwerp;
street:Main Street
```

This creates a single record containing three fields.

---

#### Creating a List Key-Value Data Source

To populate multiple records:

1. Retrieve the records you want to include.
2. Loop through the collection.
3. During each loop iteration:
   - Build the structured string.
   - Add it to the Text Collection Variable.
4. Pass the completed collection to PDF Butler.

For example, when generating a document from an Account, you might:

- Retrieve all related Opportunities.
- Loop through each Opportunity.
- Create one structured string for each Opportunity.
- Add every string to the collection.

Each entry uses the same Data Source Identifier, allowing PDF Butler to recognize that all records belong to the same List Key-Value Data Source.

Example:

```
CustomerDataSourceId|name:Opportunity A;amount:25000
CustomerDataSourceId|name:Opportunity B;amount:18000
CustomerDataSourceId|name:Opportunity C;amount:50000
```

PDF Butler automatically converts these entries into a list of records.

---

#### Passing the Data to PDF Butler

The PDF Butler Flow Action includes a parameter specifically for Key-Value Data Sources.

Pass the **Text Collection Variable** containing all of the formatted records into this parameter.

During document generation, PDF Butler reads each entry and populates the corresponding Key-Value Data Sources before processing the template.

---

#### Configure the Key-Value Data Source

Unlike standard Data Sources, PDF Butler cannot automatically determine the available fields because they are defined dynamically inside the Flow.

Therefore, after creating the Key-Value Data Source, you must manually add every field in the configuration.

For example, if your Flow sends:

```
name
city
street
```

you must manually create these fields in the Data Source configuration.

Example configuration:

| Field Name |
| --- |
| name |
| city |
| street |

The field names configured in PDF Butler **must exactly match** the field names used in the Flow.

 

 
