Flow Actions
Doc Generation Flow Actions

Merge Documents (Sync)

Introduction

The CloudFiles: Merge Documents (Sync) flow action lets you combine multiple files into a single document directly within Salesforce Flow Builder. This synchronous action delivers real-time outputs that you can use immediately in subsequent automation steps.

This feature streamlines document workflows by consolidating PDFs from various libraries—whether in Salesforce or external drives—into one file. You can then store the merged document back in Salesforce or in a custom library location.

Below is how the action appears in Flow Builder. The following sections provide detailed descriptions of the input and output parameters.

What this action does

This flow action automates the combination of multiple PDF files into a single PDF document.

Document Merging

Helps in doucument merging by -

  • Merging multiple PDF files into one consolidated document.
  • Supporting merging documents from both Salesforce Files and external libraries.
  • Retainaing the order of documents as provided in the input collection.

Storage Options

Save the merged document in Salesforce by:

  • Linking it to a specific record as a content document.
  • Placing it in a designated file library.

Store the file in external storage when using the package with the CloudFiles | Document Management & Sharing Platform

Input Parameters

Here is a list of all input parameters with a summary. For details, check out the individual sections below:

  • Resources: List of resources to be combined.
  • File Name: Name for the resulting merged file.
  • Destination (optional): Location to save the output document.

1 - Resources

The Resources parameter accepts a collection of Apex-defined variables that point to documents from Salesforce Files or external storage.

2 - File Name

This parameter defines the name of the resulting merged file.

  • Input a static name or dynamically assign one using Flow resources.
  • Example: "Merged_File.pdf" or "MergedFiles_{!Account.Name}.pdf"

This name will be visible in Salesforce Files or in the external storage location.

3 - Destination

The Destination parameter determines where the merged document will be stored after CloudFiles completes the merge operation.

Steps to Configure Destination

Create an Apex-Defined Variable of Apex Class cldfs__Resource.

To Save in Salesforce (Default Behavior):

  • If no destination is provided, the merged file is saved to Salesforce Files.
  • To explicitly link the file to a record:
    • Library: Set to salesforce.
    • Id: Set to the Record Id of the Salesforce record.

To Store in External Storage:

  • When using CloudFiles with the CloudFiles | Document Management & Sharing Platform:
    • Assign the following fields:
      • Library: External library name.
      • DriveId: ID of the connected drive.
      • Id: ID of the folder or location within the drive.

Pass the configured variable as the Destination Parameter in the Merge Documents (Sync) action.

Output Parameters

The CloudFiles: Merge Documents (Sync) action provides immediate outputs, accessible in the flow's All Resources.

1 - Document

  • This Output parameter specifies the metadata details of the generated file.
  • This parameter is populated only if the Destination input parameter is configured. If not, it will be null.

Field Details:

  • When saved in Salesforce and linked to a record -
    • Id: The generated file's Content Document Id.
    • Library: salesforce.
    • Other fields will be null.
  • When saved in external storage -
    • Contains metadata details of the file stored in the external storage.

2 - Content Version Id

  • If no Destination parameter is specified, the file is stored in the Salesforce File Library.
  • This parameter holds the Content Version Id of the generated file in Salesforce.

3 - Document Name

The name of the generated document.

4 - Download URL

A dynamic URL to download the generated file.