Creating custom link fields in Microsoft Dynamics CRM 4.0

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 hot 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;}

The 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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: