When generating documents or emails, you can define meaningful document names or subjects directly in your template, respectively. These can include both static text and values from Dynamics 365 fields, making the result clear and easy to identify.
Document name
For this example, we would like to define a dynamic document name for a contact template. This template is to be used to generate a letter that welcomes a new customer, so we would like the generated document’s name to read “Welcome FIRSTNAME LASTNAME!”
To define our dynamic name, we first need to navigate to the Document Name and Subject tab located within the Template Settings.
In the Designer tab, you can add both fields and static text to construct your dynamic name. To add text, click on the plus (“+”) button and select Add static text. We can use this to add the first part of our dynamic name.
Next, we will add the first and last name fields from the Contact table. The fields can be added to the designer by double clicking the fields from the list above. Additionally, we will include a space between the first and last name fields to separate them. Click OK once you are finished.
Tip: Additional functions can be applied to fields and text. See here for more information.
With the document name pattern saved, we can now save the template to our Dynamics 365 environment. When we generate a document from this template, we can see that the document will have a name that matches the pattern we constructed.
Email subject
Subjects for emails created during the document generation process can be set in the template separate from the document name. Defining a dynamic subject is similar to defining a dynamic document name. In fact, by default, dynamic names and subjects are set using the same value. You can set the subject separately by enabling the Set document name and subject separate setting, which will unlock a separate Subject tab.
The rules for creating a dynamic subject are the same as well. We will construct a new pattern here.
Then, if you save the template and attach it as email content or as an attachment…
The subject will be based on the pattern from the template.