This content comes from here: http://blog.davehawes.com/post/2008/04/23/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx. I have reproduced it here because it is really handy and I don’t want to loose it.
Take note: Strictly speaking this is unsupported (and the previous method for doing this broke when upgrading ver 3 to ver 4). Apparently they are going to provide a supported way for doing this in the future. Use knowingly…
Thanks Dave Hawes!
//--------------------------------------------------------------------------------------------------
HideAssociatedViewButtons = function(loadAreaId, buttonTitles){
//--------------------------------------------------------------------------------------------------
var navElement = document.getElementById('nav_' + loadAreaId);
if (navElement != null) {
navElement.onclick = function LoadAreaOverride() {
// Call the original CRM method to launch the navigation link and create area iFrame
loadArea(loadAreaId);
HideViewButtons(document.getElementById(loadAreaId + 'Frame'), buttonTitles);
}
}
};
//--------------------------------------------------------------------------------------------------
HideViewButtons=function(Iframe, buttonTitles) {
//--------------------------------------------------------------------------------------------------
if (Iframe != null ) {
Iframe.onreadystatechange = function HideTitledButtons() {
if (Iframe.readyState == 'complete') {
var iFrame = frames[window.event.srcElement.id];
var liElements = iFrame.document.getElementsByTagName('li');
for (var j = 0; j < buttonTitles.length; j++) {
for (var i = 0; i < liElements.length; i++) {
if (liElements[i].getAttribute('title') == buttonTitles[j]) {
liElements[i].style.display = 'none';
break;
}
}
}
}
}
}
} ;
To hide just the add existing btton the call is this:
HideAssociatedViewButtons('lwb_contact_lwb_service', ['Add existing Program to this record']);
To hide both buttons the call is this:
HideAssociatedViewButtons('lwb_contact_lwb_service', ['Add existing Program to this record', 'Add a new Program to this record']);
replace the bold bits with:
[Customisation Prefiix] + “_” + [Entity Schema Name] + “_” + [Customisation Prefiix] + [Entity Schema Name]
and Program with the Entity Display name
No comments:
Post a Comment