Automate DocGen Packages
You can 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 Salesforce field.
-
Create a workflow using Salesforce Flow. For more information, see the Create a Salesforce Flow workflow to specify when to send the outbound message.
When the workflow criteria are met, the message is sent, automatically generating documents that create output and deliveries specified in the DocGen Package.
Create a Salesforce field
Note: For more information on creating custom fields in Salesforce, see Create a Custom Field. In this topic, all the examples are based on the Opportunity object.
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:
-
In Salesforce, click Setup.
-
Search for Object Manager in the Quick Find box.
-
In Object Manager, search and select Opportunity.
-
On the left pane, select Fields & Relationships and click New.
-
Under Data Type, select Formula, and click Next.
-
Type Drawloop_Next for Field Label.
You must use Drawloop_Next under Field Label. If you need to create more than one field, append a number or another 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 object 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 is hard coded into the Drawloop_Next field, but can be dynamically added with a more complex formula. Delivery Option This is also hard coded, but can be 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:
-
In Salesforce Setup, search for Workflow Actions, then select Outbound Messages.
You may have to click Continue on Understanding Workflow.
-
Click New Outbound Message.
-
Select an Object in the DocGen Package you want to automate, then click Next.
-
To configure the outbound message, on Edit Outbound Message, insert a Name and Unique Name.
-
Select a user for User to send as.
-
For Endpoint URL, type in 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:
-
In Salesforce Setup, search for Process Automation and select Flows.
-
Click New Flow.
-
Select Record-Triggered Flow.
-
To configure the flow, select an Object which you want to use.
- You can select when to trigger the flow in Configure Trigger and set the condition requirements for Set Entry Conditions.
-
On the left page, add the Outbound Message element by clicking + Add Element and select Action.
-
Filter by Category, and search for Outbound Message.
-
Click Outbound Message, and select a record.
-
Search the Action list for the desired outbound message record
-
Insert a Label. The API name is automatically filled to match the label.
-
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.