Friday, December 15, 2017

MS CRM Email Template with dynamic id in link

You are trying to create a custom email to a group of contacts and want to create a URL with a contactid in the query string to customize what they see when they click on that link.

It turns out that you need to understand two things to make this work.

In the Template Editor when you press Insert/Update there is no option for the contactid.

#1 Generating a contact id


To create a contactid merge field you need to type the following which is case sensitive.

{!contact:contactid;}

Now Save the Template and this text will turn into a working merge field that returns the contact id of the contact the email is being sent to.

{!Contact:Contact;}

#2 Be careful about links in the Email Template Editor


The following two lines will not be processed the same way when the emails are sent.

The following line will be merged properly and the contact's email browser will typically display a link.

https://www.myportal.com/OrderService.aspx?id={!Contact:Contact;}&type=0


This line may surprise you since the email will look fine but the link won't work. 
https://www.myportal.com/OrderService.aspx?id={!Contact:Contact;}&type=0

What you get is the following:




Notice that the text of the link is merged, but the href value is not.


What if you want a nicely formatted link?

Please click here to find out more!

At this point I "believe" your only course of action is to manually modify the XML in the email template body in SQL. I haven't tried that yet, but will post additional information if I do.



No comments: