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 files 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.

Note:

Note: The file types supported for merging are PDF, DOCX, Images (PNG and JPEG).

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 files into a single document.

Document Merging

Helps in doucument merging by -

  • Merging multiple 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: A collection of cldfs__Resource variables, each representing a file to be merged.
  • 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 cldfs__Resourcethat point to documents from Salesforce Files or external storage. Each file you want to merge must first be defined as an individual variable and then added to the collection.

For each file, create a new variable of type cldfs__Resource. Create one variable per file (e.g., File_1, File_2).

In your Flow, use an Assignment element to assign values for each file:

  • library = "salesforce" (when the file is from Salesforce).
  • id = Salesforce ContentDocument File Id (e.g., 069dL00000A4vd3QAB).

Create a collection variable that can hold multiple cldfs__Resource items.

Use an Assignment element to add your single file variables (File_1, File_2, etc.) into the Resources collection. Then, pass this collection to the Resources input of the CloudFiles: Merge Documents (Sync) action. This ensures that the action receives the complete list of files to be merged.

Note:

Note:

1- For files from external storage, configure the following parameters:

  • Id
  • Library
  • DriveId

2- If you already have a Content Document record collection or a Resource collection from external storage, you don’t need to create multiple cldfs__Resource variables. Instead, you can define a single cldfs__Resource variable along with one collection variable. By looping through the records, you can assign values such as Id, DriveId, and Library to the single variable, and then add it to the collection.

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.