2

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.

lazarus
  • 1,997
  • 3
  • 26
  • 44

1 Answers1

2

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", "");
Grigory
  • 550
  • 3
  • 14
  • 2
    OK, first part of your answer is clear. But in my case I'm using plugin. Is there any way to get server URL in Execution method in plugin, without hardcoding? – lazarus Sep 27 '12 at 13:08
  • It has to be somewhere in IOrganizationService object, I believe. And you can get through the registry if it's OnPremises of course. RegistryKey regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\MSCRM"); string serverUrl = regKey.GetValue("ServerUrl").ToString(); – Grigory Oct 03 '12 at 08:56
  • OK, thanx. I created entity url in plugin. But obviously it is not possible to insert dynamically url in email template. Can you just edit your post with reading server url from registry key, and I'll mark your answer as accepted. – lazarus Oct 04 '12 at 12:52
  • 2
    I've found one more way. We can use WhoAmIRequest wich returns UserId, OrganizationId and BusinessUnitId as GUIDs. WhoAmIResponse whoAmI = (WhoAmIResponse)Service.Execute(new WhoAmIRequest()); Having Organization Id there is no problem to get Organization information. – Grigory Oct 10 '12 at 11:22