CRM Software Logo

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


38 Responses to “Dynamic Values for Custom Entities in Email Templates”

  1. Tal says:

    This works with template type: Global?

    • Mike Watt says:

      Hi Tal,
      This will technically work for a template of any type, but in order to create an email template that references custom entities it has to be of Template Type: Global.

      • Jeff says:

        Is this possible to do? I’m using CRM 2016 and it doesn’t seem to work at all.

        • Mike says:

          I tried it with CRM 2016 and it worked fine. The field references are case sensitive so make sure that is correct. For example if I wanted to show the Account name it would be {!account:name;No name found}

          • Vitor Amaral says:

            Hey Mike,

            Account is a supported entity for using email template on. I can do it as well, but for other entities such as Campaign, even following the structure that shows above, i am not able to get a yellow dynamic tag upon saving the record.

            Can you check and see if you can do it for Campaign?

          • Mike says:

            Hey Vitor,
            Thanks for reading, I was able to get it to become yellow, make sure you have the casing right, here are two examples I did that worked for me,
            The Campaign’s Code {!campaign:codename;}
            The Campgin’s Name {!campaign:name;}

  2. Michael says:

    Thanks for the tip. It works fine but has issue with regarding: Creating Entity with an invalid parent. Entity: Email, ReferencingAttribute:regardingobjectid
    I’m wondering why crm sdk doesn’t have this syntax. Do you know if we could find it documented some where?

    • Mike says:

      Hi Michael,
      I’ve looked far and wide for any sort of documentation on this and have found nothing from Microsoft.
      As far as your question, I’m not sure I’m answering it, but I believe the issue might be that when setting the dynamic values it’s trying to insert the values based on the regarding object. Meaning it’s trying to find the ‘Regarding Object’ from the entity it’s regarding, which unless it’s an email it probably won’t have.
      Hopefully that makes sense, let me know if there are any other questions.

      • MIchael says:

        Hi Mike,
        The issue was in the setting. Emails are not allowed for the custom entity. The workaround is to create a child workflow (Custom action) and send a proper entity there as a parameter and then query the related entities.
        Yeh, it’s so pity about lack documentation from MS. Is there any other source?

  3. Mike says:

    I tried it with the Campaign entity and it worked. The string I used was {!campaign:name;No Name Found}

  4. Hamid says:

    Can you imbed dynamic fields straight into HTML Code then paste it in the email body. If so, what is the code that needs to be entered into the HTML code

    • Mike says:

      Hey Hamid,
      I believe what you’re asking is if you can combine html with the dynamic values? I was able to, here’s a simple hyperlink anchor tag that grabs the website url from the account and uses the account name as the text,
      Let me know if that answers your question

      • Mike says:

        well apparently you can embed hyperlinks into the comments
        so I tried to show, within an anchor tag, I set the href=”{!account:websiteurl;}” and then in between the start of the anchor I added {!account:name;}
        This sets the link to the accounts url and the text as the account name

  5. Stina says:


    Did you find a way to retrieve data from related entities?

  6. Daniel says:

    Thanks for this great blog entry!

    While i was experimenting with above knowlege two questions came up to my mind.

    1. How can I retrieve the URL of the record? I want to include the URL in my E-Mail.
    2.In reference to Hamid’s comment above: Could someone provide me the html5 code you’re using to embed hyperlinks with comments? (I have very little knowlege of html5 but the idea you’re describing sounds great)

    Any help is appreciated 🙂

    • Mike says:

      Hey Daniel,
      So, unlike with dialogs and workflows, where you can select Record URL (Dynamic) from the side menu, there’s nothing really similar to that from here. However I did find a bit of a work around. all you really need to open a new record is the server name (just your crm url), entity name and entity id.
      So within an anchor tag, for the href you could do something like this.

      {Server Name}/main.aspx?id={Entity Id}&newWindow=true&etn={Entity Name}&pagetype=entityrecord

      So for the entity id, we can use a dynamic value, and since by default the lookup dynamic values populate with the id or GUID, we can use that.
      For Entity name we can just hard code that with the entity’s logical name.
      So for example if we wanted the url to the contact record, the url would look similar to,{contact:contactid;}&newWindow=true&etn=contact&pagetype=entityrecord

      and as usual, when you save the template, the contact area should turn yellow if you did it correctly.
      Let me know if you have an further questions!

      • venkatesh says:

        Hi Daniel ,

        I have this requirement to show the record link in my email content.
        could you please let me know if Mike’s solution worked for you.
        How you resolved it.


  7. Daniel says:

    Hi Mike, Hi Venkatesh,

    sorry for replying so late…
    Well I did find a solution but I was using a different workaround.
    The dataset is created via workflow. I just added another step to the workflow which updates the data with the URL. Therefore I added a field on the custom entity which then contains the URL of the Dataset.

    In the e-mail template I therefore can relate to the field with the URL. In combination with the href you can have a nice link to the dataset which shows the name but if you click on you get forwareded to the dataset.

    If you got further questions feel free to ask. I’ll try to check this website from time to time again.

  8. Pavan says:

    Hi Mike,

    I have a requirement to incremented value every time a new mail was sent out with that particular template for a case.

    Can this be done ? Let me know if you found out a way.

    Thanks for all the information 🙂

    • Mike says:

      Hi Pavan,
      Thanks for reading!
      Can’t think of a super clean way to do this…
      We’d need to persist that incremented value somewhere.
      I’m not sure where though…perhaps we could add a field on the case? though the incremented number wouldn’t be persistently consistent through all cases…

  9. Pooj says:

    Hi Mike,

    Thank you for all the information, are really helpful. I have a question of how to format the date from MM/dd/yyyy to dd/MM/yyyy in an workflow email body.
    Value I get currently:
    Workflow body
    Date & time received: {Created On(Case)}
    Output Email body
    Date & time received: 2/9/2017 9:43 AM (this is 9th Feb 2017)

    This happens while the server as well as client date format already have formatted to be Australian Date Format which is dd/MM/yyyy h:mm tt.

    Thank you in advance,

  10. Mike says:

    Hey Pooj,
    Sorry for the really slow response. I was trying to think of a work around but nothing comes to mind. Displaying dates has always been a sore spot for me with CRM. I do mention how to display just the date, but I believe it does it based on the Organization’s base date format. Wish I had a better thought or idea for you. I’d love to hear if you thought of a work around for this.

    Thanks for reading,

  11. Krish says:

    Hi does this functionality work in Dynamics 365?I tried it, not working. My publisher name is different its not “new”. Can you let me know is there any work around?

    • Krish says:

      Sorry mate its working perfectly on Dynamics 365. i have just tested again. Thanks for the blog really useful

  12. Chris H says:

    Wow…this is a real gem! I have worked with several clients that needed this and had no idea it existed. Where did you find documentation on this???

    • Mike says:

      That’s the strangest part, I didn’t. I had to kind of hunt through their code to find it all. I was and still am pretty shocked they don’t have any documentation on this.

  13. Denise McDonough says:

    Trouble getting to work with Dynamics 365. In a global template, if I copy & paste in dynamic fields from a custom template, it works. If I try to type in exactly the same dynamic fields, it doesn’t put the yellow box on them and doesn’t translate them in the template, eg.
     {!Contact:Account Name;} (shows with yellow highlight) and {!Contact:Account Name;} (typed in, no yellow highlight).

    I’ve tried this with many different entities and fields. I’m doing this to test it works before I move on to my real goal which is to pull in fields from a custom entity.
    Any suggestions?

    • Mike says:

      Hey Denise,
      Thanks for reading! Sorry for the late response. I believe the issue is that you’re not using the correct schema name for the field. There are a few ways to find these technical names, one is by opening the form editor on the entity (usually located under the eclispes in the ribbon bar area of an entity), then double click the field you’re looking for, in this case that would be the Account Name field on contact. From that pop up, go to the ‘details’ tab, and the name in the Name field is what you will use, so this would be parentcustomerid. Also the entity needs to be in it’s technical name. I could tell you how to find that if you’d like as well, for Contact it’s s easy as just all lower case, contact (custom entities are a little more tricky)
      So try typing the following
      I added the ‘/@name’ because it’s a lookup and this will give you the name of that account (ass opposed to a GUID)
      Hope that helps, again sorry for the slow response!

  14. Harsh says:

    Hi Mike,

    I have a requirement where I have text line field say ‘Code’ contains numeric value like (123456789) and in email template I need to format the value of field as 12345-6789.

    Is it possible to format this fields dynamic value on template itself?


    • Mike says:

      Hi Harsh,
      Thanks for reading. As far as your request, I don’t believe this is possible using the dynamic values. I couldn’t find any way to format values that it retrieves.
      If you do find a way, please let me know, I’d be very interested.


  15. Paul O'Toole says:

    Is there a way to link fields from related entities using this approach?

    • Mike says:

      Hey Paul,
      I looked some and couldn’t find any way of getting the values from a related entity. I could only get it to use values from the regarding field record. Please comment if you do find a way


  16. Alizadeh says:

    Thanks for the lesson…

    I remember one of my clients asked me to do this and at that time, had no idea how… and now I see it was this easy.

  17. Glady says:


    I’m trying to insert fields in an Invoice email template to include project information. Under record type, it only allows fields to be selected from Users, Accounts, Contacts, and Invoices. I need to add fields from Projects. I used your article as a guideline and the field turned yellow, but when generating the email, the field came back blank.

    Ex: Address:{!Project:Project Address Line 1;} 

    And feedback on why I’m getting a blank return?

    • Hi,
      I can only think of two issues:

      1. The regarding object is Invoice, and you’re attempting to get the information off of a related entity Project, which it doesn’t currently seem possible with this. The dynamic values can only come from the regarding object you have selected. In order to get the information for Project the Project record needs to be the regarding object.

      2. My other thought, I’m not totally sure if this is true, but it sounds like you may have made the Template type Invoice? Again, I cannot confirm this to be true right now, but I believe this makes the system think it’s only looking for field values on Invoice, and you’re trying to get them off of project. So I think the Template might need to be of record type Global in order to use Project

      And finally as I was typing I noticed one more thing, in your example, you pasted the following,
      Address:{!Project:Project Address Line 1;} 
      and I noticed the field you have, Project Address Line 1, is using the display name, but not the schema name. The schema name doesn’t have any spaces, and for custom entities (which I believe Project is) usually looks something like new_projectaddressline1, where new can be what ever prefix you selected.

      Hope that helps! Let me know if not, and thanks for reading!

      -Mike Watt

Ask This Expert a Question / Leave a Comment


Show Buttons
Hide Buttons