Flow Actions

Generate Document (Batch)

Introduction

The CloudFiles: Generate Document (Batch) action allows you to automate the generation of multiple documents in a single action within Salesforce Flow Builder. It simplifies the process of handling multiple document generation requests, reducing complexity and increasing efficiency for bulk operations.

Unlike the Generate Document action, which processes a single document at a time, the batch action takes a collection of input configurations and generates multiple documents asynchronously, each based on its respective template and parameters.

Below is how the action looks like. Detailed descriptions of the input and output parameters are provided in the following section.

Document image


What This Action Does

The Generate Document (Batch) action processes a collection of document generation inputs in a single execution, where each input corresponds to a single document generation request. It automates bulk document creation with the same advanced features available in the standard Generate Document action.

Each variable in the collection input can specify a unique Generate Document action. Each Each processed input publishes a Document Generated event, which can be used to trigger additional automations or workflows.

Example Use Case:

A sales team needs to generate multiple Opportunity documents records in one go when the status is updated to 'Closed-Won'. Instead of using multiple Generate Document flow actions in the flow, a single Generate Document (Batch) action can be used to generate all the documents based on the input paramters.

Input Parameters

The Generate Document (Batch) action has a single input parameter:

Inputs

A collection of Apex-Defined Variables of the class cldfs__GenerateDocumentFlowInput.

Document image


Each cldfs__GenerateDocumentFlowInput represents the input configuration for generating one document and contains the same fields as the parameters for the Generate Document action:

  1. CloudFiles Variables: Runtime variables for template placeholders.
  2. Destination: Where to store the generated document (Salesforce or external storage).
  3. Document Type: Format of the generated document (PDF, DOCX, PPTX, XLSX).
  4. Record ID: Salesforce record ID for pulling data.
  5. Parameters: Advanced security settings for PDF documents.
  6. Template: Template ID to be used for document generation.

Steps to Configure the "Inputs" parameter

  1. Create individual Apex-Defined Variables of the cldfs__GenerateDocumentFlowInput class for each document.
  2. Populate each variable's fields with the respective configuration values (e.g., template ID, destination, and record ID) as you do for a single Generate Document action.
  3. Add all these variables to a Collection Variable of the same class cldfs__GenerateDocumentFlowInput
  4. Input the Collection Variable into the action's Inputs parameter.

Output Parameters

The CloudFiles: Generate Document (Batch) action operates asynchronously, meaning it does not provide immediate outputs after execution, instead publishes events for each processed input.

Document Generated Events

Each document generation request (individual input) publishes a Document Generated event upon successful processing. Use these events to trigger downstream automations or flows, such as notifications or additional processing.

Error Handling If an input fails to process, an Error Event is published for that specific input. These events can be used to identify and handle issues with individual document generation requests.