Hiding custom buttons in CRM 4.0 Toolbar


In CRM 3 it was possible to hide a button on a toolbar just by calling the document.getElementById(“”).style.display = “none” method.

This will NOT work in CRM 4.0. The ID of the button seems to be generated when the CRM Form is loaded. One time it might be ISV_New_1_MyButtonID the other time it might be ISV_New_39_MyButtonID.

A simple workarround is by checking all the LI items in the UL of the MenuBar and by comparing its ID with “MyButtonID”.
To do so use the following javascript in the forms OnLoad event:

HideButton = function()

{

var ULListItems = document.getElementById(“mnuBar1”).rows[0].cells[0].getElementsByTagName(“UL”)[0].getElementsByTagName(“LI”);

for(var i=0; i<ULListItems.length;i++)

{

if (ULListItems[i].id.indexOf(“MyButtonID”) > -1)

{

ULListItems[i].style.display = “none”;

break;

}

}

}

// Execute the function when loading the form

HideButton();

// Execute the function when the form is resized.

window.onresize = HideButton;

Advertisements
Tagged with: ,
Posted in CRM 4
3 comments on “Hiding custom buttons in CRM 4.0 Toolbar
  1. […] buttons reappear when resizing a crmForm Filed under: CRM 4 — kennyvaes @ 17:13 In a previous post  I described how to hide custom buttons in a toolbar. When a CRM form is resized by the user it […]

  2. David Withers says:

    I’m a tab confused what I need to change to look for a specic button.

  3. Kenny Vaes says:

    Hi, thanks for pointing this out.
    There seemed to be some lines missing in the code.
    I updated the post.

    Just replace MyButtonID in the line “if (ULListItems[i].id.indexOf(“MyButtonID”) > -1)” with the ID of the button you are searching for.

    Regards,
    Kenny

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

%d bloggers like this: