Email Field - Double Click to Open in Outlook (CRM4)

תשובה Email Field - Double Click to Open in Outlook (CRM4)

  • mercoledì 10 settembre 2008 01:29
     
     

    I found the following code which opens the outlook email form and prepopulates the email address field when the emailaddress1 field is clicked in CRM4.

     

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

     

    This works great.

     

    However, I can't figure out how to make it work for other email fields on the same form (emailaddress2 and emailaddress3) so that if a user clicks on an email field (either emailaddress1, emailaddress2, or emailaddress3), the Outlook email form will pop up with the correct email prepopulated in the To field.

     

    I tried adding several modified versions of the above code to the onLoad event but non of them have worked. For example, if I add the following code to try to get emailaddress2 to work, the event for emailaddress1 above no longer works.

     

    if (crmForm.all.emailaddress2 != null)
    { crmForm.all.emailaddress2.ondblclick = function()
        { var email = crmForm.all.emailaddress2.DataValue;
            if ((email != null) && (email.length > 0))
            { window.navigate("mailto:" + email);
            }
        }
    }

     

    I really appreciate any help you can give me on this!

    Kyle

Tutte le risposte

  • mercoledì 10 settembre 2008 11:05
    Proprietario
     
     Con risposta

    Kyle,

     

    Try this, I will put it on my blog later.

     

    Code Snippet

    /* Double Click EmailAddress to Open in Outlook */
    function CreateEmail(emailAddress)
    {
        return function()
        {
            if (emailAddress != null && emailAddress.value.length > 0)
            {
                window.navigate("mailto:" + emailAddress.value);
            }
        }
    }

    crmForm.all.emailaddress1.attachEvent('ondblclick', CreateEmail(crmForm.all.emailaddress1));
    crmForm.all.emailaddress2.attachEvent('ondblclick', CreateEmail(crmForm.all.emailaddress2));
    crmForm.all.emailaddress3.attachEvent('ondblclick', CreateEmail(crmForm.all.emailaddress3));

     

     

     

    Cheers,

    Jim

  • mercoledì 10 settembre 2008 12:56
     
     

    Just to complicate matters further - would it be possible within the JavaScript to ensure that the Outlook email is 'tracked in CRM' with the Regarding set to the contact?

     

    I'm assuming it doesn't do this by default.

  • domenica 12 ottobre 2008 01:42
     
     

    Hi Jim,

     

    I didn't see your reply until today for some reason. Thanks, I will try that.

     

    Kyle

  • domenica 12 ottobre 2008 01:48
     
     

     

    Tried it and it works great!

     

    Thanks!

    Kyle