We need to place the below code on form load event of the CRM form.
/* Code to Add Menu to CRM FORM */
if (document.getElementById("_MBCustomActionMenu") == null) {
/* Create an Span Link to Menu */
var eles = "<SPAN class='ms-crm-Menu-Label-Opened'><A class='ms-crm-Menu-Label' tabIndex='-1'><IMG class='ms-crm-Menu-ButtonFirst' tabIndex='-1' alt='CustomActions' src='/_imgs/mnu_actions.gif'><SPAN class='ms-crm-MenuItem-Text' tabIndex='0'><U>C</U>ustomActions</SPAN><IMG style='CLIP: rect(0px 11px 16px 0px); BACKGROUND-IMAGE: url(/_imgs/imagestrips/control_imgs_1.gif); WIDTH: 11px; BACKGROUND-POSITION-Y: -32px; HEIGHT: 16px' id='IMG1' class='ms-crm-Menu-DownArrow' alt='More' src='/_imgs/imagestrips/transparent_spacer.gif'></A><A class='atLink' title='Open the Accessible form of the Actions menu' tabIndex='-1' onclick='return false;' href='javascript:onclick();' target='_self'></A></SPAN>";
/* Create the Menu Items */
eles += "<div style='display: none;'><ul class='ms-crm-MenuList' id='mnuaction'>";
for (i = 0; i < 5; i++) {
eles += "<li tabIndex='-1' class='ms-crm-MenuItem-Label' id='_MIlocAddObjTo"+i+"' action='locAddObjTo("+i+");'><SPAN class='ms-crm-MenuItem-Label'><A class='ms-crm-MenuLink' tabIndex='-1' onclick='return false;' href='javascript:onclick();' target='_self'><SPAN class='ms-crm-MenuItem-Icon'></SPAN><SPAN class='ms-crm-MenuItem-Text' tabIndex='0'>Test Action "+i+"...</SPAN></A></SPAN></li>";
}
eles += "</ul></div>";
var mnu = document.createElement("li");
mnu.className = "ms-crm-Menu";
mnu.title = "Custom Actions";
mnu.tabIndex = -1;
mnu.accessKey = "C";
mnu.menu = "mnucustomactions";
mnu.innerHTML = eles;
var ele = document.getElementsByTagName("ul");
for (i = 0; i < ele.length; i++) {
if (ele[i].className == "ms-crm-MenuBar-Left") {
ele[i].appendChild(mnu);
break;
}
}
}
No comments:
Post a Comment