You can email a generated document automatically with a Salesforce flow. First, you add an email template and email settings to your document solution. Then you build a record-triggered flow that calls the ASync Document Generate Solution hic_docmerge Apex action.

Before you begin

Set up the email in your document solution

  1. Go to Document Setup and click the pencil icon next to your document solution. The solution opens for editing.

  2. On the Add Email Template tab, create the email template that the flow sends.

  3. On the same tab, select Email and enter the email details. Click Save, then click Next. Docs Made Easy saves the email settings to your solution.

    Email settings for the solution with the Save and Next buttons

Create the flow

  1. Click the Setup icon at the top right of the screen, enter Flow in the Quick Find box, click Flows, and then click New Flow. The new flow dialog opens.

  2. Select Record-Triggered Flow, then click Edit next to Configure Start. The Configure Start panel opens.

  3. In Configure Start, select your object and set the trigger that you need.

    Configure Start panel with the object and trigger settings

  4. Select Free Form, then drag the Action element from the left side of the screen onto the canvas. The New Action page opens.

  5. In the Action field, search for and select ASync Document Generate Solution hic_docmerge. Then fill in the required fields, such as Label and API Name.

    New Action page with the Docs Made Easy action, label and API name

  6. In the documentSolutionId field, enter the ID of your document solution. The document solution ID is the part of the solution's URL that is highlighted below.

    Browser address bar with the document solution ID highlighted in the URL

  7. For the record ID, enter the triggering record's ID, {!$Record.Id} (in the resource picker, choose Triggering Record > Record ID), and click Done. Salesforce adds the action to your flow.

  8. On the canvas, connect the start element to the Apex action element. Save the flow, then click Activate.

Test the flow

  1. Open a record of the object you chose (for example, an account) and update it so that it meets your trigger conditions.

  2. Go to the Related tab and refresh the page. The generated file appears in both Files and Notes & Attachments, and you can open it. The recipients that you set up in your solution receive the email.

    Generated file listed in Notes and Attachments after refreshing

The email is sent through Salesforce, so Salesforce email limits apply, and it's recorded in the record's activity history. If nothing happens, check the Salesforce debug logs for the flow run.

Related: Automate document generation with Flow · Email the generated document as an attachment in background mode