---
title: Dynamically Controlling PDF Butler Components with Salesforce Flows
description: "[Component DocConfigs and Packs by Flow logic](https://www.youtube.com/embed/j3tBlg8sDwg?feature=oembed)   PDF Butler components provide a powerful way to generate documents and preview content directly from Salesforce. However, in many business scenarios, static component configurations are not flexible enough. For example, you may…"
url: "https://pdfbutler.com/academy/pdf-butler-academy/pdf-butler-lightning-components/dynamically-controlling-pdf-butler-components-with-salesforce-flows/"
updated: "2026-06-10"
category: PDF BUTLER LIGHTNING COMPONENTS
---

# Dynamically Controlling PDF Butler Components with Salesforce Flows

[Component DocConfigs and Packs by Flow logic](https://www.youtube.com/embed/j3tBlg8sDwg?feature=oembed)

 

PDF Butler components provide a powerful way to generate documents and preview content directly from Salesforce. However, in many business scenarios, static component configurations are not flexible enough.

For example, you may want:

- Different Doc Configs based on Opportunity Stage
- Different Packs based on Record Type
- Different document alternatives depending on business rules
- Locale-specific document generation
- Dynamic Previewer configurations

Instead of creating multiple components with complex visibility rules, PDF Butler allows you to use **Salesforce Flows** to dynamically control which configurations are displayed.

This guide explains how to use an **Auto-Launched Flow** to dynamically configure PDF Butler Components and Previewers.

---

#### Create an Auto-Launched Flow

The Flow used by PDF Butler must be an:

**Auto-Launched Flow**

This Flow will be responsible for:

1. Receiving information about the current record.
2. Determining which configurations should be available.
3. Returning those values to PDF Butler.

---

#### Create the Input Variable

PDF Butler passes information about the current record into the Flow.

To access this information, create a Flow variable.

1. Create a New Resource
    Resource Type: Variable
    API Name: `input`
    *Important: The variable name should be `input` using a lowercase "i".*
2. Variable Configuration
    Data Type: Apex-Defined
    Apex Class: `ComponentDataByFlowInput`
3. Enable Input Access
    Check:`Available for Input`
    *If this option is not enabled, the Flow will not receive any information from PDF Butler.![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.03.55-300x137.png)*
4. Create a Get Record to Opportunity
    Filter by ID:  *input.recordId
    ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.06.57-297x300.png)*

---

#### Create the Doc Config Output Variable

To return Doc Config IDs to PDF Butler, create a collection variable.

- Variable Name: `docConfigs`
   lowercase "d"
   uppercase "C"
- Data Type: Text
- Allow Multiple Values: Enabled
- Available for Output: Enabled
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.07.44-300x115.png)

Create a Get Record to Doc Config Object and Loop it to all Doc Config

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.08.46-1-296x300.png)

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.14.53-1-300x209.png)

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.16.08-1-300x148.png)

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.15.37-1-300x222.png)

---

#### Configure Previewer Packs

Previewers can also be controlled dynamically.

Create another collection variable.

- Variable Name: `previewerPackIds`
- Data Type: Text
- Allow Multiple Values: Enabled
- Available for Output: Enabled
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.18.32-1-300x113.png)

##### Populate Previewer Packs

Retrieve Pack records and loop through them.

Add each Pack ID to the collection:`previewerPackIds.ADD(Pack.Id)`

PDF Butler will display those Packs in the Previewer component.

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.16.47-1-300x155.png)

![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.17.19-1-300x131.png)

---

#### Configure Alternatives

Alternatives can also be set dynamically.

- Variable Name:`alternative`
- Data Type: Text
- Collection: Disabled
- Available for Output: Enabled
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.19.35-1-300x135.png)

---

#### Configure Locale

Locales can also be controlled by Flow.

- Variable Name:`locale`
- Data Type: Text
- Collection: Disabled
- Available for Output: Enabled
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.18.56-1-300x136.png)

---

#### Configure a Single Pack

In some situations, you may want to show a single Pack instead of a list of Doc Configs.

For this purpose, create another output variable.

- Variable Name:`packId`
- Data Type: Text
- Available for Output: Enabled
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.20.39-1-300x202.png)
   At the end your flow will be looking like similar to this one below:
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.22.18-1-300x139.png)
   ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.23.17-1-300x147.png)

---

#### Connecting the Flow to a PDF Butler Component

After building the Flow, connect it to the PDF Butler component.

1. Open the Lightning Page
2. Navigate to:`Edit Page`
3. Select the PDF Butler component.
4. Configure the Flow Name
    **fields such as: Doc Configs, Packs, Locales, Alternatives are left empty.**
5. Only populate:`Flow Name`
    Populate the Flow Name with the Flow API Name
    ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.25.10-1-300x113.png)*![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.24.51-1-300x145.png)*

---

#### Using Flows with the Previewer Component

The same concept applies to the Previewer component.

Instead of configuring:

- Packs
- Doc Configs
- Alternatives

directly on the component, you can provide only a Flow Name.

The Flow then dynamically controls everything displayed in the Previewer.
 ![](https://pdfbutler.com/wp-content/uploads/2026/06/Screenshot-2026-06-10-at-07.26.51-1-300x152.png)

---

By combining PDF Butler Components with Salesforce Auto-Launched Flows, administrators can dynamically control document generation and preview behavior without relying on static component configurations.

This approach provides maximum flexibility and allows document generation behavior to adapt dynamically to any Salesforce business process.
