Monday, September 29, 2008

Embedding related record link in Email


The code below is not a replacement to the well known workflow + plug-in solution. This is a simple service function that I usually add to the email entity onload event, so when a user clicks on the send email toolbar button the opener ( related entity ) link is embedded in the email body.

Users find this extremely comfortable since even if you don’t send the email to a co-worker as a direct reference when the email comes back it very handy to be able to open the record from within outlook like a bookmark.


function OnCrmPageLoad()
{
if( crmForm.FormType == 1 && opener )
{
var opnrLoc = opener.location;
var relUrl = "http://" + opnrLoc.host + opnrLoc.pathname + opnrLoc.search;
var ifrmDoc = document.all.descriptionIFrame.contentWindow.document;

var relLink = iframeDoc.createElement( "A" );
relLink.href = url;
relLink.innerText = "Related Record";
ifrmDoc.body.appendChild( relLink );
}
}

OnCrmPageLoad();

1 comment:

Unknown said...

I find this extremely comfortable to cope with; thanks for sharing - at least, I am sure you will find some time to get the esl enquirer for all your academic purposes!