# CloudFiles Merge Documents

Let users order files, merge them into one PDF, check it in a preview and save it to the record, with the CloudFiles Merge Documents component in a Salesforce Screen Flow.

> Kind: Flow action · Updated: Nov 27, 2026

The CloudFiles Merge Documents component lets users merge several files into one PDF inside a Salesforce Screen Flow. Users put the files in order, merge them, check the result in a preview and save it to the record without leaving Salesforce. It works with Salesforce Files and files in any connected library. To merge in the background from a record-triggered, scheduled or autolaunched flow, use Merge Documents (Async) instead.

![The Merge Documents screen on an Account record page, with four files listed in merge order and the first one previewed](https://media.help.cloudfiles.io/fa-cloudfiles-merge-documents-sf/block-2-062c6f7b.png)

## 1. Collect the files to merge

The component merges the files in Source Files, in the order they are listed. It takes a collection of Resource variables. For each Salesforce File, set the variable's Id to the file's ContentDocument Id, its Name to the name users should see, its Type to file and its Library to salesforce, then add it to the collection. Files from other libraries also need their Drive Id, which the Resources returned by CloudFiles flow actions already carry.

To merge a record's files, use Get Records on ContentDocumentLink for the record, then loop over the files and add each one to the collection with an Assignment. The Merge documents tutorial walks through the same steps.

![An Assignment element that sets a Resource variable's id, name, type and library for a Salesforce File and adds it to the merge list](https://media.help.cloudfiles.io/fa-cloudfiles-merge-documents-sf/block-6-271b827c.png)

## 2. Set the destination

Create a Resource variable for Destination, which is where the merged PDF is saved. To save it to the record the flow runs on, set Library to salesforce and Id to the record Id. To save it to a folder in another library, set Library, Drive Id, and Id to the folder's Id.

Leave Destination blank to let users preview and download the merged PDF without saving it. The merged PDF is then kept for 24 hours.

## 3. Add the component to a screen

Add a Screen element. Search the components for CloudFiles Merge Documents, drag it onto the screen and set its inputs:

| Input | What it does | Default |
|---|---|---|
| Source Files | The files to merge, in merge order. See step 1. | None |
| Destination | Where the merged PDF is saved. See step 2. | None |
| File Name | Name of the merged PDF. | Merged Document - date and time |
| Open Preview | True: the merged PDF opens in a preview and is saved when the user clicks Save file. False: Merge saves the file straight away and moves to the next screen. | True |
| Show Download | Shows Download in the preview. Users also need the Allow Downloading permission. | True |

![The CloudFiles Merge Documents component selected in the Flow Builder screen editor, with Destination, File Name, Open Preview, Show Download and Source Files in the properties panel](https://media.help.cloudfiles.io/fa-cloudfiles-merge-documents-sf/block-13-5b6d108a.png)

The component has its own buttons. Open Configure Footer in the screen's properties and untick Show Footer, so users don't see two sets of buttons.

The component returns Merged Document, which is the saved file, and Error Message. With no Destination, Merged Document is the merged PDF kept for 24 hours. Error Message is blank on success. Otherwise it says why the save failed, or why the user moved on without merging. To show a different screen when nothing was saved, check Merged Document in a Decision after the screen.

## 4. Add the flow to a page

Save and activate the flow. Then open the record page where users should see it, click the Gear icon and select Edit Page. Drag the Flow component onto the page, select your flow and tick Pass record ID into this variable for its recordId variable. Save the page and activate it.

To let users pick the files in the CloudFiles widget instead, start the flow from a custom list action at flow/Your_Flow_Name?resources={!resources}&recordId={!recordId}. The flow's resources variable then holds the files the user ticked, and you can pass it straight to Source Files. See Setting Up a Custom List Action in the CloudFiles Widget.

## Merging files

Users click a file in Merge order to preview it, change the order with the arrows and leave a file out with ×. Merge joins the files into one PDF and converts Word, PowerPoint and image files to PDF along the way.

With Open Preview on, the merged PDF opens in a preview. Users can page through it and download it, or click × to go back to the merge order, change it and merge again. Save file saves the PDF to the destination and moves the flow on. With no Destination, that button says Next or Finish instead.

![The merged five-page PDF open in the preview, with page thumbnails, a Download button and a Save file button](https://media.help.cloudfiles.io/fa-cloudfiles-merge-documents-sf/block-22-18ad7a5a.png)

## What each user can do

The screen runs as the person using it, so files in other libraries are read and saved through their own connection to that library. The component merges every file the flow passes in, so pass only files the user should be able to see. Download also needs the Allow Downloading permission.

A user without a Document Generation license sees: You need a Document Generation license to merge files.
