Custom Dynamics CRM 2011 ToolTips

Dynamics CRM 2011 does not support custom tooltips or any other built-in method for delivering helpful information to the user when filling out a form. The code snippet below will popup a tooltip and display a custom tooltip on as many of the CRM form fields as you like. Just attach this code to you CRM form onload event.

function OnLoad() {
CreateToolTip("img_equipmentneeded", "Provide a brief history of why the services or equipment are needed.");
}

var Tooltip = null;

function CreateToolTip(controlId, toolTip) {
var control = document.getElementById(controlId);

control.ToolTip = toolTip;

control.attachEvent("onmouseover", ShowToolTip);

control.attachEvent("onfocus", ShowToolTip);

control.attachEvent("onmouseout", HideToolTip);
}

function ShowToolTip() {
var control = event.srcElement;

Tooltip = window.createPopup();

var ToolTipHTML = "<DIV style='width:100%;height:100%;border:1px solid gray;background-color: #d8e8ff;filter: progid: DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr=#ffffff,EndColorStr=#cecfde);padding-left:2px;font:12px tahoma'>" + control.ToolTip + "</DIV>";

Tooltip.document.body.innerHTML = ToolTipHTML;

var Width = control.offsetWidth;

var Height = 30;

var Position = GetControlPostion(control);

var Left = Position.X + 1;

var Top = Position.Y + 1;

Tooltip.show(Left, Top, Width, Height, null);
}

function GetControlPostion(control) {
var Position = new Object();

var controlHeight = control.offsetHeight;

var iY = 0, iX = 0;

while (control != null) {
iY += control.offsetTop;

iX += control.offsetLeft;

control = control.offsetParent;
}

Position.X = iX + screenLeft;

Position.Y = iY + screenTop + controlHeight;

return Position;
}

function HideToolTip() {
if (Tooltip)

Tooltip.hide();
}

OnLoad();

 

Advertisements

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s