As a result of some great questions that I received on my first blog, Dynamic Values for Custom Entities in Email Templates, I wanted to write a follow up blog highlighting the resolutions to some of those inquires. I’m going to assume you’ve read the previous entry, which is posted above.
Template Types
When creating a new email template, you first get prompted to select an Email Template Type.
If you select a Template Type aside from Global, you must have a record matching that type in either the Regarding field or any of the Send To, CC, or BCC fields. You will also be able to easily insert dynamic values into the template for that record type. If you so choose, you could write out the dynamic values as I had shown, but it’s much easier to use the out of the box method to select them.
With global templates, you can insert the template regardless of what entity record you select:
The Global Template Type is what you’d want to use for custom entities, or any other entity not listed in the template type drop down menu. And just to reiterate, regardless of the way you insert values, whether you use the out of the box insert method or you manually type it in, you can only insert values from one record.
The Inclusion of HTML
There were also some great questions around HTML. For starters, all of these dynamic values can be used, like all templates, with HTML code. For example, if we wanted to bold a dynamic value, we could put the dynamic value between a bold tag, seen here:
After inserting the template, you’ll notice the bold text is now visible:
Furthermore, if you have a field value that is a URL, you can insert this value into the href on an anchor tag and create a dynamic hyperlink in your email:
This will be displayed as:
Dynamic URL Pointing to CRM Record
Someone asked about creating a dynamic URL that pointed to an actual record within Dynamics CRM. I was optimistic that something similar to the ‘Record URL (Dynamic)’ that you can find when creating a dialog existed. But unfortunately, this isn't the case.
However, I did find a work around! In order to open a record with a URL, all you need is the server name (which is just your CRM URL), the entity logical name, and the entity ID. Then using those three components, we can include them within our href on our anchor tag:
{Server Name}/main.aspx?id={Entity Id}&newWindow=true&etn={Entity Name}&pagetype=entityrecord
*Note: You might notice we have a few other options. "newWindow=true" just means we want to open this URL in a new window. "Pagetype=entityrecord", just means we want to open the entity record.
We should know the Entity Logical Name already. If not, it should be easy to find, and looking at the URL, we can get the Server Name. So the only thing we are missing is the Entity Record ID, but we can get this using our dynamic value. Usually (you may need to check the fields on your entity to confirm this), the ID field is the entity name plus ‘id’. For my football team entity, this field is new_footballteamid. If we let our server have the IP name of 192.168.1.1, we now have all the information we need to create the URL and insert it into the href of our anchor tag.
This will be displayed as:
Well that’s all for now. As always, please don’t hesitate to ask any questions!
-Go Broncos
Written By Mike Watt, Developer at
hmmm... how about using output parameters from Action. How will I format the dynamics value given by Action?
Hey Sean,
Thanks for reading, sorry it's taken a second to get back, holiday week and all.
I believe if I'm reading this correctly, this is definitely possible, since you can't embed html in these comments (it will convert it to html and not super helpful), try surrounding the following within an anchor (a) tag,
href="mailto:{!lead:emailaddress1;}?Subject=Hello {!lead:fullname;}" target="_top">Send E Mail
This will create a mail to hyperlink with the text Send E Mail, that when clicked, will have the Send To as the lead's emailaddress1, and it will have the subject Hello and the lead's fullname.
I believe that's what you're asking
Is it possible to set the href properties of mailto and subject from fields on a Dynamics CRM entity record such as lead? I am wanting to add a clickable email address in the body of my email template.
The goal is to have a Lead notification email template which is sent is sent out to a sales rep. When the sales rep clicks on the lead's email address in the body of the Lead notification email, a new (reply) email opens which should populate the To and Subject of the reply email with the Lead's email address and the Subject based on values found from the Lead record
I am not able to find the correct syntax to generate the href string.
Is it possible to do something like this in the Dynamics CRM Email Template?
Sean,
Please see Mike's response to your question. Thanks!
Hi,
Great post.
I would like to use the "Global Email Template" in a WorkFlow FOR A TASK.
The workflow is on the "Task" entity.
--Set the template: "Owning User".
--Set Page Properties: The Owning User was set in the CC.
But I cant put in the "Regarding Field" to the Task.
So the Email, does not incluido the values of the field names of TASK.
Please your help would be useful
Thank you for the post - very helpful.
2 follow-up questions:
A - If I am using the template to create an email to a sales lead, how do I insert the Lead Owner's signature?
B - Is there a way to dynamically insert a jpg based? i.e. the lead is asking about a specific model, how can I insert an image of the model?
Thank you again,
Andrew
Hey Andrew,
For question A, I think you might be out of luck. I'm not super familiar with signatures, but they seem to some kind of other entity. I don't think it would be possible without some code, and even then I'm unsure.
In regards to question b, I'm not sure I'm totally following. My main question is where is the jpg image? if it's a note, then I don't think you could use it with these dynamic values as the note is a separate related entity and we can drill into those...
However I was thinking, if there was a web resource that was this jpg model in your CRM, you could add a field (or use an existing field) called something like Model Web Resource URL, and this would just be the URL to the image in CRM (you could also host the images somewhere and get their url that way). And then in your email template add a basic html img tag, and for the src attribute, us the dynamic value to that new field, and presto it will use that image. You'd obviously need to add the images to CRM or host them, and then on creation of the lead, set that value.
Hey Andrew,
Thanks for reading! Sorry for my slower response.
In regards to your question, what I think you're saying, I believe is possible. From what I gather, you'd like to send an email when a record is updated?
So, let's say when an order gets updated, to send an email with the correct template. So not sure your familiarity with workflows, but, what I'd do is set up a new workflow that starts when record field changes, select all fields you wish to send it on.
Then select under Add Step, the Send email, select use template and which entity you'd like to use. then set properties, and select your template and set the regarding to the order in this case.
To do a more dynamic Regarding field, you'd just need to some how get the record into the context of the workflow, not knowing your exact situation, I'm not too sure how to do that in your case. Happy to help if you need more help and can help me better understand that.
One other nifty feature that could really help if you're using the same entity for multiple different entities, you can add multiple entities to the same dynamic value, and if one is null it will check the next, and so on, so let's say we want the same template for orders and invoices. Let's say we want to use the name of the document, so to do that we can just enter
{!invoice:name;salesorder:name;Document Number}
this first tries to get the name of the invoice, if that doesn't exist, goes to the name of the order, and if that doesn't exist it will use the default value of Document Number.
Let me know if I can help any more!
Mike
This is great to know! Is it possible to generate a workflow which automatically sends the email/template to a record which is updated. so, essentially, the Regarding is auto-populated?
Hello,
I am facing a problem where if I only add lookup fields then this does not work and If I add a single line of text field as well with the lookup fields this works.
Is this a known issue or am I doing something wrong with this?
u might need /@name after the logical name and before the semi colon
read the first part of this article: https://www.crmsoftwareblog.com/2015/11/dynamic-values-custom-entities-email-templates/