CRM Software Logo

Microsoft Dynamics 365 & Dynamics CRM experts provide reviews and opinions to aid professionals with the Dynamics 365 selection process.

 
 
Mark Rockwell, Rockton Software

Dynamic Values for Email Templates – Part 2

Email | Print

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.

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:

Select Record

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:Dynamic Value Bold

 

After inserting the template, you’ll notice the bold text is now visible:

Dynamic Value Bold-2

 

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:

Field Value URL

 

This will be displayed as:

Field Value URL Result

 

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 Rockton Software, a Microsoft Dynamics CRM add-on provider.

7 Responses to “Dynamic Values for Email Templates – Part 2”

  1. Amey says:

    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?

  2. Andrew Marshall says:

    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?

  3. Mike says:

    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

  4. Andrew says:

    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

    • Mike says:

      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.

  5. Roxana says:

    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

Ask This Expert a Question / Leave a Comment

 

 
 
Show Buttons
Hide Buttons