Friday, June 25, 2010

Remove Add Existing Button From CRM Iframe in MS CRM 4.0

/* _MBtoplocAssocOneToMany2contactcustomeraccounts is the Id of the AddExisting button appearing in CRM grid. this id can be find out using IE developer tool bar */

function RemoveAddExistingFromIframe()
{
var iFrame1 = null;
iFrame1 = crmForm.all.IFRAME_Test;
var iDoc1 = iFrame1.contentWindow.document;
iFrame1.attachEvent( "onreadystatechange" , Ready1);
RemoveWhiteSpace(iFrame1);
}

function Ready1()
{

var iFrame1 = crmForm.all.IFRAME_Test;
var iDoc1 = iFrame1.contentWindow.document;
if(iDoc1.getElementById("_MBtoplocAssocOneToMany2contactcustomeraccounts") != null)
iDoc1.getElementById("_MBtoplocAssocOneToMany2contactcustomeraccounts").style.display = "none";
}


function RemoveWhiteSpace(iframe)
{
try
{
var IFRAME_test = iframe;
IFRAME_test.onreadystatechange = function ()
{
if( IFRAME_test.readyState != 'complete' )
return;
IFRAME_test.style.border = "0px";
var IframeWindo = IFRAME_test.contentWindow;
IframeWindo.document.body.scroll = "no";
IframeWindo.document.body.childNodes[0].rows[0].cells[0].style.padding = "0px";
}
}catch (e)
{alert('Error : '+e);}
}

No comments: