Bite my bytes

What I learn by day I blog at night - A blog from Microsoft Consultant working from Ljubljana, Slovenia

  Home :: Contact :: Syndication  
  999 Posts :: 7691 Comments :: 235 Trackbacks


Most popular posts
in last 360 days


My Projects



Copyright © by David Vidmar
Contact me!
LinkedIn Profile

The regular nvarchar attribute with URL format is useless for anything else but link with http/https and ftp/ftps schemes.



To make things worse, if you put in link with a protocol that is not recognized by CRM validation code, http protocol gets automatically appended. So forget about using skype, navision, magnet, msnim or any other URI schemes!


Also, did you notice how useless Email format is? You can’t click and send an email to address from you default email client!

But there is a simple JavaScript trick that can be used to convert any regular nvarchar field on a form to clickable link field!

We want to turn the link into blue and underline it. Using same CSS style as for build in URL format is not the way to go, since it includes CSS behavior that validates schemes and adds http URI scheme if none is used.


We can recreate the look and feel with just a few lines of code. Put it in OnLoad event and substitute attribute name.

var emailTextBox = crmForm.all.emailaddress1; = "#0000ff"; = "underline";
emailTextBox.attachEvent("ondblclick", openEmail1);

function openEmail1() {
if (emailTextBox.DataValue != null)
document.location = "mailto:" + emailTextBox.DataValue;

This is end result – colored and underlined email that you can double-click it.


You can change first parameter of attachEvent to “onclick” if you prefer single click.

Posted on Tuesday, March 02, 2010 11:32 PM | Filed under: Developement MS Dynamics CRM |


# re: Creating custom link fields in Microsoft Dynamics CRM 4.0 3/20/2010 12:01 PM Brett Gilbertson
Thank you so much for this. that been looking for a solution to link to OneNote URLs, and this will do the trick perfectly.

Didn't think of the Skype url example. Might throw that in too.

# re: Creating custom link fields in Microsoft Dynamics CRM 4.0 7/20/2010 10:46 PM Brian
Excellent. Works perfectly. I also added code to change the cursor to a hand when hovering over the email. Here it is:

emailTextBox.attachEvent("onmouseover", mouseover);
emailTextBox.attachEvent("onmouseout", mouseout);

function mouseover() { = 'hand';
function mouseout() { = 'auto';

# re: Creating custom link fields in Microsoft Dynamics CRM 4.0 7/20/2010 11:03 PM David
Brian, thanks for the tip!

Comments have been closed on this topic.