- Blog Blog



How do I create a document and attach it to an email in a single workflow step in MS Dynamics 365 Online?

This step-by-step tutorial outlines how to create a document and attach it to an email in a single workflow-step.

Requirements: DocumentsCorePack ServerBased, MS Dynamics CRM 2015/2016 or MS Dynamics 365

Step 1: Create a new workflow
First, open Dynamics 365 (CRM) and navigate to Settings ❶ and Processes . In the My Processes-area click on the [New]-button ❸ in order to create a new workflow.

Figure 1: Add a new process


Please type in a Process name ❶ (here: Test Workflow), set Workflow as Category , select the entity you would like to create the workflow for  (here: Account), and click on the [OK]-button in order to finish the creation of your new workflow. 

Figure 2: Create a new workflow

Step 2: Add your workflow details

If we want to receive a good result for our workflow, we first have to create an email. To do so, please click on the [Add Step]-drop-down-button ❶ and select Create Record. Type in a name for your step  (here: Create Email) and use the Create:-drop down menu ❸ to set the Create:-section to Email. Next, click on [Set Properties]-button .

Figure 3: Create an eMail record


An email activity opens. In this window, a sender, a subject and an email text ❺ has to be defined. The form assistant supports you when it comes to the setting of the Recipient-field . The Regarding-field ❻ is often already pre-filled. If not, simply follow the same instructions as for the Recipient-field for the Regarding-field. 

Please set the cursor into the Recipient-field ❶ in order to set the recipient. Next, select Account in the Look for:-drop down menu ❷ in the Form Assistant-area on the right sight, click on the [Add]-button ❸ and then on the [OK]-button . Now the Recipient-field is filled out correctly. 

Figure 4: Configure the email activity

Optionally, you may scroll down and configure some more details of the eMail step. 

Once you have finished the configuration, please click on the [Save and Close]-button.

Next, we want to create a new AutoMerge Working item, which makes sure that the document is generated and attached to the email properly. To do so, please add a new step. Again, click on the [Add Step]-button and select Create Record. Then, type in a step description and use the Create:-drop down menu to set the Create:-section to AutoMergeWorkingItems. Next, click on the [Set Properties]-button.

In the window that opens now, we set the properties for the next step. To do so, please name the AutoMergeWorkingItem  (here: Create and Attach) and set an AutoMergeAction  using the drop-down menu (here: CreateDocument). 


Figure 5: Name the AutoMergeWorkingItem

Next, it is important to make sure that the workflow contains all the important settings that are necessary for a smoothly running process.
Apart from the name and the AutoMerge Action, it is important to fill in the following fields:

 the PrimaryRecordsUrl-field
❷ the TemplateToExecute-field 
❸ the SaveAs-field
and ❹ the EmailToAttach - field

Figure 6: AutoMergeWorkingItems

Please find further information on how to insert the single fields below. 

1) How do I set a PrimaryRecordsUrl-field?
To do so, please set the cursor in the PrimaryRecordUrl-field  ❶ and go to the Look for:-area ❷ within the form assistant on the right side. Next, select Record URL(Dynamics) ❷ from the second drop-down-menu, click on the [Add]-button ❸ and then on the [OK]-button .

Figure 7: Insert the PrimaryRecordsUrl


2) How do I select a template to execute?
To determine the template that should be executed during the workflow, simply set your cursor in the TemplateToExecute-field and look for the template you would like to add.

Figure 8: Select a template

How do I set a file format?
The Save As- field enables you to select a certain file format. In order to define it, simply use the drop down menu of the field. 

How do I define which eMail should be attached?
Next, set the cursor into the EmailToAttach-field  and select Create Email (Email) in the form assistant ❷ on the right side. Please note: It is of utmost importance also to select an eMail here. Next, click on the [Add]-button . Once you have finished the configuration, please click on the [Save and Close]-button  in order to save your settings. Additionally, it is possible to send the document via eMail if you insert the created eMail (see 1, 2 & 3) also into this field

Figure 9: Attach eMail 

Now your workflow settings are finished and the workflow is ready to be used. Please do not forget to save the workflow before you proceed! 

Figure 10: Workflow - ready to use 

Step 3: Activate your new workflow

Please select your newly created workflow in the My Processes-section and click on the [Activate]-button in the command bar. 

Figure 11: Activate workflow 


In the following question dialog, click on the [Activate]-button in order to proceed. 

Figure 12: Activate the process



Comments are closed.