Friday, November 13, 2009

Easy Emailing from a CRM Contact Record

Has anyone else wanted to be able to click on the email address on a form in CRM and have it email that person/record? Or at least bring up an email message form that can be filled out and sent?



Yes, on the Contact form there is the "Send Email" button, but that sends a CRM email and personally, I'm not a huge fan. They're great for templates but other than that I very much prefer the Outlook experience of emailing.



So, the other day I came up with a good way to get the functionality that I really wanted. I used some script from one of my coworkers that turns the label of a field to a button and then modified the onclick action. Here's what the buttons look like:


And when anyone clicks on the buttons it will take the corresponding email address and use your default mail client (most likely Outlook) and open up an email message for you:


This is all done with script and with only a little fiddling the form is now so much more functional now. And for all you coders out there, here's the part you want, the code:

/********Email Button Creation********/
// Replace the attribute new_button with the button and create a link to the onclick function

function CreateEmailButton() {
var fieldTable = crmForm.all.emailaddress1_c;
var html = "<input onclick='Email_Button_OnClick()' value='Primary' type='button'>";
fieldTable.innerHTML = html;
}
// Function to be triggered onClick
Email_Button_OnClick = function()
{
window.location = "mailto:" + crmForm.all.emailaddress1.DataValue;
}
CreateEmailButton();


It's the little things in life that make us happy, so why not make your CRM users happy by adding some simple solutions to make their jobs easier? I don't necessarily mean this solution, but anything that makes it so that people don't have to do the same function 50 times a day sure brings a big smile to their face :).
David Fronk
Dynamic Methods Inc.

2 comments:

NZRegs said...

the timing of this article is most amusing. I was discussing this exact customisation internally the day before you published.

taking your code and doing a crude modification i get the original label plus an email icon to click instead of turning the whole label into a button:

function CreateEmailButton() {
var fieldTable = crmForm.all.emailaddress1_c;
var oldContents = fieldTable.innerHTML;
var html = oldContents + "[img onclick='Email_Button_OnClick()' value='Primary' src='/_imgs/ico_16_138.gif'/]";
fieldTable.innerHTML = html;
}

(square bracked swapped for angle bracket to allow post)
Some proper CSS formatting around this would make it look even more attractive of course..

Dynamic Methods said...

NZRegs,

I'm glad that this was timely enough to help you out. Thanks for addition to the code.

David Fronk
Dynamic Methods Inc.

Post a Comment