Use Nintex DocGen with Flow
Nintex DocGen includes the Run DocGen Package action that can also be used in Salesforce Flow, and a Preview Screen component for Flow Screens that can be used in Flow. With Flow you can automate document generation processes based on an event trigger in a Salesforce object. For example, with Flow you can create a workflow that automatically generates a contract when an Opportunity reaches the "Closed Won" stage.
For more information on how to use Flow in Salesforce, see Flow Builder , or view the relevant Salesforce Trailhead modules. You can also access a sample flow using DocGen from the AppExchange.
The following actions are available to use with Nintex DocGen in Flow:
- Run DocGen Package: An Apex action that can be added to a workflow to automatically generate and deliver documents in the background once an event happens, such as a record is updated/created.
- Preview DocGen Screen A component that displays the process of a DocGen run, and includes the option to allow end users to download the generated files via a link.
Using either approach allows you to build scenarios such as:
-
Generating a document anytime a user updates or creates an Account or Opportunity.
-
Prompting a user answer a few on-screen questions before generating a proposal.
Important: Each user who initiates Flow workflows must have a Nintex DocGen license as these workflows are triggered and run by the end-user.
Using the Run DocGen Package action
Caution: Since the DocGen Package runs in the background for this workflow, do not use the Download delivery option in the DocGen Package, as there is no interface to retrieve the documents. Instead, use an Attach or DocQueue delivery option.
-
Gather option IDs from DocGen Package metadata
-
Before you select and configure a workflow with Flow, you will need to gather the following option IDs:
-
DocGen Package ID
-
Delivery Option ID
-
Record ID
-
Contact ID (optional)
-
Attach ID (optional)
-
-
How to find option IDs
-
The easiest way to find the option IDs listed above is to open the appropriate records and locate their IDs. Once the IDs are located, store the record IDs in a convenient place for future reference.
-
In Salesforce Lightning, click on the View DocGen Package metadata panel to find the list of option IDs.
-
-
-
Click the App Launcher menu and type "Flows" in the search field. Select the Flows option in the search dialog.
-
From the Flows screen, click New. If you are updating an existing Flow then select one from the menu and skip to Step 6.
-
In the New Automation window, select the flow type that is required.
In this example, we are adding a flow based on an event being triggered in a record. Locate and select the Record-Triggered Flow or search for the desired flow type in the Search automations field.
-
Select the Salesforce object that is going to contain the field or action to trigger the flow. In this example, we are selecting Account in the Object field.
-
Click Add Element to open the Add Element dialog box.
-
In the search field, search for and select Run DocGen Package.
-
Set the following values for these fields:
Tip: The following fields are populated with using the information you gathered in Step 1 for the option IDs.
- Label: RunDocGen (or any label you want to use)
- API Name: This label is automatically entered, but you may change based on your needs
- DocGen Package Id: {!DocGenPackageID}
- Delivery Option Id: {!DeliveryOptionId }
- Record Id: {!RecordID}
- Record Ids: {!CollectionofRecords}
- Contact Id: {!Send_To}
- Attach Ids: {!AttachIds}
-
Once you have added the values for these fields, and filled out any other desired information, click Save to save the Flow.
Important: Only one of the Record ID or Record IDs field can be used. If a value is provided for both, only Record ID will be used.
If you want to generate documents for a batch of records using the Record IDs field, you will need to use a Text Collection variable:
-
Use the Query records action to get a Record Collection of record IDs (Record Collection is a specific type of collection).
-
Convert the Record Collection into a Text Collection. In your Flow you will be able to Query for a Record Collection of IDs. Then use the Loop and Assignment variable to convert the list to a Text Collection:
-
Create a Loop action that accepts the Record Collection and extracts the Record ID to a Single Text Variable.
-
Create an Assignment action that adds the value of the Single Text Variable to a Text Collection Variable.
-
Create an Apex Action using the Run DocGen Package Apex action that uses the Text Collection Variable in the Record IDs field.
-
Using Preview DocGen screen component
Use the Preview DocGen screen component to display and generate documents in real time with the Manage Delivery Options for DocGen Package below that do not require user interaction.
Some Delivery Options listed in the table below are AutoSend only. Also, some eSignatures do not support Embedded Signing. See the table below for details.
| Delivery Option | AutoSend and other options |
|---|---|
| Download | All |
| Attach | All except Content- User Selected |
| Salesforce Email | AutoSend only |
| SMTP | AutoSend only |
| Adobe Sign | AutoSend and no Embedded Signing |
| DocuSign | AutoSend and no Signing Preview and Edit, or Embedded Signing |
| OneSpan Sign | AutoSend and no Embedded Signing |
| Sertifi | AutoSend and no Embedded Signing |
| SignNow | AutoSend only |
| DocGen Queue | All except Content- User Selected |
| Content Delivery | Not allowed |
| Start Nintex Workflow | AutoSend only |
Drag Preview DocGen from the Screen Components Pane A DocGen Run that is starts from a user's action, implicitly started (such as changing a field), or a scheduled process. Also known as Auto Run. to the Screen Canvas The process by which a user performs an explicit action to trigger a DocGen Run., then set the following values for these fields required fields:
- Type - (Custom): Preview DocGen
- API Name - Enter, "previewDocGen" or any text you want to use for this field
- DocGen Package ID - {!DocGenPackageID}
- Record Id - {!RecordID}
The following fields are optional:
- Contact Id - {!Send_To}
- Attach Ids - {!AttachIds}
- Success Message - Enter any text that you want to display once the documents are generated
Required options for Preview DocGen Screen component
- Open SalesforceFlow from Salesforce Setup, create a new Flow, then deploy the Flow Screen Component for the page layout to your end-users. (The Preview DocGen screen is only available for screen flows.)
- Click the Manager tab > New Resource and configure the options listed in the table below. The API names in the table below are examples, but you can choose to use them if needed.
| Field | Resource type | API name | Data type | Available for input | Allow multiple values (collection) |
Description |
|---|---|---|---|---|---|---|
| recordID | Variable | recordId | Text | Enabled | N/A | Required if generating documents for a single record. |
| CollectionOfRecords | Variable | recordId | Text | Disabled | Enabled | Required if generating documents for multiple records at once. |
| DeliveryOptionID | Variable | DeliveryOptionId | Text | Enable | N/A | The record ID for the delivery option when the DocGen Package is run. |
You can set the following optional variables as needed for your generated documents.
| Field | Type |
API name |
Data type |
|---|---|---|---|
| ContactId | Variable | contactId | Text |
| AttachIds | Variable | accountId | Text |
Migrating from using Outbound messages to Flow
If you were using Outbound messages (OBMs) to generate documents, typically from the Session ID, you can migrate this process to Flow. By using the Run DocGen Package action, you can replicate the behavior of your previous process by building a simple workflow in Flow. For more information on setting up a Flow utilizing the Run DocGen Package, refer to Using the Run DocGen Package action.