Creating Email Templates in Microsoft Dynamics CRM a very simple task, on the surface. You write what the Subject will be, followed by the Body of the message, and just like that you’ve created an email template. However, there are instances when you might want to add some Dynamic values based on the record. Inserting dynamic values from out of the box entities like User, Account, or Contact is pretty straightforward. At the top of the template select Insert/Update:
From there, simply select the Record type, and the field you want to insert. Here’s an example of what using the Contact’s First name would look like within the template:
That’s easy enough, but what if you want to add Dynamic values from a custom entity? According to the Software Development Kit (SDK), it says:
. . .
Well it doesn’t say anything actually, but not to worry, there is a way. In the template, where you want the value to appear, type within 2 brackets an exclamation point followed by the entity logical name. After the entity name, add a colon, and then the field logical name, ending it with a semi colon. If you’d like a default value if nothing was found, after the semi colon add the default value.
{!<entitylogicalname>: <fieldlogicalname>; <Default Text>}
For example, let’s say we have an entity called football team, and we want our template to use the Football Team’s Team Name field, and if it’s empty use Denver Broncos. In order to do this, we would type:
{!new_footballteam : new_teamname; Denver Broncos}
After saving it will look like this:
Single line of text fields are easy enough, works the same for most fields: currency and numbers. Dates will return the Date and Time value. In order to return just Dates add at the end of the fieldlogicalname, /@date. Similarly for just the Time portion, add /@time, for example:
{!new_footballteam:new_firstsuperbowlvictory/@date;}
{!new_footballteam:new_firstsuperbowlvictory/@time;}
Option Set Values will return the numerical value. In order to return the Friendly name add /@name,
{!new_footballteam:new_conference/@name;}
Lookups return the GUID value, to return the Primary Attribute’s Friendly Name, add /@name,
{!new_footballteam:new_currentquarterback/@name;}
These are all of the methods we’ve found so far. We are hoping to find a way to retrieve data from related Entities, but as of now it seems to be nearly impossible.If you have any feedback around tricks with email templates, comment to add your feedback.
Follow @RocktonConnect on Twitter to stay updated with tips and tricks for Microsoft Dynamics CRM.
Go Broncos!
Written By Mike Watt, Junior Developer at Rockton Software, Accounting Inside of Microsoft Dynamics CRM.
The post Dynamic Values for Custom Entities in Email Templates appeared first on CRM Software Blog.