JavaScript Conversion: Removing unnecessary code #1. Adding mailto to an email-enable text field

  • Home >>
  • DynamicsCRM >>

Occasionally I will run into JavaScript that was added to a form to provide functionality desirable by the business.

I have seen several instances where code such as this:

 

if (crmForm.all.emailaddress1 != null)
{

    crmForm.all.emailaddress1.ondblclick = function ()
    {

        var email = crmForm.all.emailaddress1.DataValue;

        if ((email != null) && (email.length > 0))
        {
            window.navigate("mailto:" + email);
        }
    }
}

 

Has been added to turn an email-style text field into a hyperlink that will launch the user’s default email editor when clicked or double-clicked.

The code above is unnecessary because Dynamics CRM 2011 offers this feature by default so any instance of this code can be safely removed and the functionality will still exist.

This is not a huge deal, but it is one less piece of code that needs to be maintained.

Leave a Reply 0 comments