Have you ever tried creating a workflow that sends an email, and embedded in that email is a link to the affected record? If you have, you probably know by now that there is no direct way to do it.

So here was my requirement: When an Account changes ownership, update the Account territory and send an email to the new Owner. Embedded in this email has to be a link to the Account.

This should have actually be included with most entities in CRM, seems to be an ommission in my mind.

So here’s the simplest work-around:

Create a new attribute on the entity, let’s name it new_AccountLink. Now, here, make sure that you select these options:

Type: nvarchar

Format: URL

Maximum Length: I usually put 250, but has to be an arbitrary number long enough to account for your URL and a GUID.

I display thins field on the form, either on the Administrative tab, or on a tab I hide afterwards in JavaScript in OnLoad.

On the OnSave event, add the following script, which will compose the URL to the entity, and populate the new field with it. You will then use this field’s value to get the URL in a workflow email:

crmForm.all.new_accountlink.DataValue = ‘http://crm/sfa/accts/edit.aspx?id=’ + crmForm.ObjectId;

And this is it. Simple enough!

Also, use instead of accts:

  • conts for Contact
  • opps for Opportunity

or just retrieve the URL from the entity you need.