How to insert record url into email template?

lazarus picture lazarus · Sep 10, 2012 · Viewed 7.7k times · Source

I have email template of type 'Case'. Is there any way to add URL in body text of related case?

How can I get record URL in plugin?

Thanx.

Answer

Grigory picture Grigory · Sep 11, 2012

In Emails and Dialogs you can add hyperlink in visual designer. Here is the video about inserting an url Part 3: CRM 2011 Business Process Tips & Tricks (RichardKnudson)

Maybe you can create a workflow where you create an email and add a link into it. In email body the link markup looks like that:

<hyperlink>
   <name>Link name</name>
   <value>Link URL</value>
</hyperlink>

In plugins I compose an url from several parts, server part + organization part + link to edit form of the entity.

Link to oppotunity for example:

1. ServerUrl = "http://192.168.0.1"
2. OrgName = "TestOrg"
3. OpportunityGuid = "96a63042-13d4-40b3-a4db-c024ffb64979"

var Link = String.Format("{0}/{1}/userdefined/edit.aspx?etc=3&amp;id=%257b{2}%257d", ServerUrl, OrgName, OpportunityGuid);

If it's OnPremises You can get ServerURL from the registry.

RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM");
string serverUrl = regKey.GetValue("ServerUrl").ToString().Replace("/MSCRMServices", "");
serverUrl = serverUrl.Replace("/MSCRMServices", "");