Automate DocGen Packages
Use a workflow and an outbound message to automate generating documents. There are three high-level steps:
-
Create a field in Salesforce that includes references to all the fields a user would manually select to generate documents.
-
Create an outbound message and bind it to the field.
-
Create a workflow that specifies when to send the outbound message.
When the criteria for the workflow are met, the message is sent, automatically generating documents that create output and deliveries specified in the DocGen Package.
Note: You can automate DocGen Packages using Salesforce Flow. For more information refer to the Create a Salesforce Flow workflow section.
Create a Salesforce field
Create a field in Salesforce that includes references to all the fields a user would manually select to generate documents.
To create a Salesforce field:
-
Navigate to a record on an object you want to use to generate documents and then select the View Fields link.
-
On the Custom Fields & Relationships related list for the object you're working with, click New.
-
Under Data Type, select Formula and click Next.
-
Under Field Label, type Drawloop_Next.
You must use Drawloop_Next under Field Label. If you need to create more than one field, append a number or some other character, but always start the string in Field Label with Drawloop_Next.
-
Under Formula Return Type, select Text and click Next.
-
Type the formula using these guidelines (the formula is inserted by the Insert Field function built into Salesforce):
-
Append the letters SF to all object names.
-
Pass all relevant objects IDs.
You can find object IDs in the URL. For example, to find the Salesforce ID for a Delivery Option, navigate to the Delivery Option detail page and examine the URL.
-
Specify a DocGen Package ID and deployment type.
Example: "SFobject_name__c:" & ObjectId & ";SFanother_object__c:" & AnotherId & ";DDPId:static Id;Deploy:staticid"
Formula reference
Parameter Description SFobject_name__c The API name of the object the DocGen Package is based on with the letters SF appended to the front. ObjectId A record ID from the object the DocGen Package is based on.
SFanother_object__c (Optional) The API name of another object with data you want to include in the DocGen Package with the letters SF appended to the front.
AnotherId (Optional) The record ID from another object you want to include in the DocGen Package.
DDPId:static Id The static ID of a DocGen Package. Deploy:staticId The Salesforce ID of a Delivery option. Note: For more information on where you can find the DocGen Package ID and Delivery ID, see View DocGen metadata . The Download Delivery option is not supported for Workflow DocGen Packages.
-
Some delivery options take the DeployType parameter. If you use a delivery option that takes DeployType, use this syntax: Deploy:StaticId: DeployType: Value
Example: If you want to specify a Salesforce email Delivery Option, it would look like this: DeployType:autoemail;
Delivery Option Deploy Type Salesforce email autoemail SMTP autosmtp
HTTP Service autohttpservice Document Queue documentqueue DocuSign (Legacy) autodocusign DocuSign (DAL) autodocusignal Note: If your DocGen Package contains images or reports, see If your DocGen Package contains images or a report.
Understanding the parts of the formula field
You can understand the individual parts of the automated formula field by looking at the manual DocGen Package deployment.
Summary of the important aspects of the manual experience:
Element Description DocGen Package Main Record ID This ID appears in the URL. The app automatically pulls this ID when the user clicks Generate Documents. Account ID This ID appears in the URL. The app automatically pulls this Account from the record on which the user clicks Generate Documents.
Contact ID The app gets the Contact ID from the manually selected contact. DocGen Package ID The app gets the DocGen Package ID from the manually selected DocGen Package. Delivery Option The app gets the Delivery Option from the manually selected delivery method. Run Trigger the DocGen Package Process, initiate the DocGen Package You can understand the individual parts of the automated formula field by looking at the manual DocGen Package deployment.
Element Description DocGen Package Main Record ID The formula automatically pulls this from the main record. Account ID The formula automatically pulls this from the Account related to the main record.
Contact ID The formula automatically pulls this from the contact related to the main record. DocGen Package ID This was hard coded into the Drawloop_Next field, but could have been dynamically added with a more complex formula. Delivery Option This was also hard coded, but could have been made dynamic with a more complex formula field. Run The Workflow rule we tie the Outbound Message to will automatically trigger this DocGen Package.
-
-
Click Next twice, and then click Save.
Create a new outbound message
After you create the Drawloop_Next formula field, you must add the field to an outbound message that can send all the necessary IDs to Nintex.
To create a new Outbound Message:
-
Under Setup click Create, Workflow & Approvals, and then Outbound Messages.
You may have to click Continue on Understanding Workflow.
-
On All Outbound Messages, click New Outbound Message.
-
Under Object, select the object on which the DocGen Package you are trying to automate is based and click Next.
For example, all the samples in this topic are based on the Opportunity object.
-
On the outbound message configuration page, type a name under Name and Unique Name.
-
Under User to send as, select a user.
-
Under Endpoint URL, type https://api.docgen.nintex.io/package/111.
-
Select Send Session ID.
-
From Available Fields, select Drawloop_Next and click Add. Drawloop_Next is the field you created. It should appear in Selected Fields with ID.
-
Click Save.

-
Update the Drawlop_Next fields with additional parameters.
Update the field used for OBM with the following at the end of the current value:
-
Production:
userid:{userId};sandbox:false
-
Sandbox:
userid:{userId};sandbox:true
-
-
Replace {userId} with the record ID for the User set as the User to send as on the Outbound Message for Production and Sandbox orgs.
-
Click Save.
Create a Salesforce Flow workflow
After you create an outbound message, you must create a workflow rule using Salesforce Flow. This workflow rule must be able to trigger an outbound message.
To create a Salesforce Flow rule:
-
Complete the Setup of the Create a Salesforce field
-
Complete Configuration of the Create a new outbound message.
-
Navigate to Flows in Salesforce Setup.
-
Click the New Flow button.
-
Select Record-Triggered Flow option.
-
Configure the Start Event Object, Trigger, and Conditions.
-
Click Done.
-
Add the Outbound Message Element. Click the + to add an element.
-
In the Interaction menu click Select Action.
-
Filter by Category using the Filter By field.
-
Select outbound message.
-
Search the Action list for the desired outbound message record
-
Provide a label for the outbound message.
-
Click Done.
-
Click Save and then click Activate to enable the Salesforce Flow.

After you create an outbound message, you must create a workflow rule that can trigger the outbound message.
To create a workflow rule:
-
Under Setup click Create, Workflow & Approvals, and then Workflow Rules.
You may have to click Continue on Understanding Workflow.
-
Click New Rule.
-
From Object, select the object on which the DocGen Package you are trying to automate is based and click Next.
For example, all the samples in this topic are based on the Opportunity object. -
On the workflow rule configuration page, in Rule Name, type a name.
-
In Evaluation Criteria and Rule Criteria, select the criteria you want to trigger the Outbound Message.
-
Click Save & Next.
-
In the workflow action editor, click Add Workflow Action and choose Select Existing Action.
-
On Select Existing Actions, from Choose Action Type, select Outbound Message.
-
From Available Actions, select the outbound message you created and click Add.
-
Click Save.
-
In the workflow action editor, under Action, confirm that your outbound message is displayed, and then click Done.
-
On the workflow rule page, click Activate.