web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

(CRM 4.0) Hiding Custom ISV Toolbar buttons and keeping them hidden when resizing window

(0) ShareShare
ReportReport
Posted on by

Hi,

This i another issue I've been having some troubles with.

I can hide the buttons no problem but when I resize the window they keep coming back. I tried and read several answers on it but none seems to work so far.

Here's the situation:

I have 2 custom buttons on the toolbar. They both have to be hidden based on conditions such as if a field has a certain value and I also managed to achieve that.

Like I said it's when resizing everything gets messed up with the page eventually going "berserk" and closing because of script handling.

I'm starting to feel this might me a CRM problem as even with a simple alert I maximize and minimize a form 2 times in a row and it starts throwing errors.

I'm hoping  someone can elucidate me on this and possibly provide a piece of code that is proven to work.

Thanks a lot.

PS I am using CRM 4.0 not 2011

 

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Muhammad Adeel Javaid Profile Picture
    5,580 on at

    I am suggesting a Javascript to hide unneeded ISV Buttons. It will go like this:

    // hide ISV buttons that don't apply

    function hideISVButton(buttonTitle) {

      var comps = document.getElementsByTagName('li');

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

        if (comps[i].title == buttonTitle)

        {

          comps[i].style.display = "none";

          break;

        }

      }

    }

  • Community Member Profile Picture
    on at

    @Guido

     

    I see, the problem I'm facing is exactly that. I can't remove the buttons cause they are indeed dependant on a field value.

    One of the problems is I can't pass the buttonid as it's dynamic in CRM 4 so it will change evrytime the page gets loaded. I can only get away with the button title.

     

    Summarizing what I have is a button that is to be used one time only. Before it has been used it's available and shown. Once you click on in one time, a field will get updated and it will never show for that record again.

    So it's kind of a one time operation button. Once you did it you're not supposed to do it anymore.

    Any clues/examples on how to attach a javascript function to the resize event?

    @Muhammad

    That's similar to what I have working at the moment and I can hide the buttons. The problem is when I resize the window they become visible again.

    So that code won't do the full job.

  • Suggested answer
    Muhammad Adeel Javaid Profile Picture
    5,580 on at

    Then the solution is as suggested below:

    In the OnLoad handle hiding the ISV buttons in a separate funtion and attach the onresize to the form.

    attachEvent(“onresize”,HandleButtons);

    function HandleButtons() {

       // HandleButtons

       switch (parseInt(crmForm.all.statuscode.DataValue)) {

       case 3:        // Received

           HideIsvButton(new Array(“Assign to Investigator”, “Assign to Coordinator”, “Approve Complaint”, “Close Complaint”));

           break;

       case 6:     // Register

       …

    }

  • Muhammad Adeel Javaid Profile Picture
    5,580 on at

    I think that something like form rendering is causing that.

  • Suggested answer
    Muhammad Adeel Javaid Profile Picture
    5,580 on at

    Here is another suggested code and a link to follow too:

    This code should be placed in the onload of the form.

    HideButton = function()

    {

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

    for(var i=0; i -1)

    {

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

    }

    }

    }

    // Execute the function when loading the form

    HideButton();

    // Execute the function when the form is resized.

    window.onresize = HideButton;

    You can also refer to this link as it might also be helpful for you:

    social.microsoft.com/.../3b9722d1-866d-4fcc-beff-162e53a93ac4

  • Verified answer
    Community Member Profile Picture
    on at

    The only snippet I got working is:

    function HideButtons () {

    // Hide the "Send E-mail" and "Follow Up" buttons...

    var liElements = document.getElementsByTagName('li');

    // Get the tooltip value for the button.

    var buttonTitles = ['Send E-mail','Follow Up']

    for (var j = 0; j < buttonTitles.length; j++) {

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

    if (liElements[i].getAttribute('title') == buttonTitles[j]) {

    var elem = liElements[i];

    elem.parentNode.removeChild(elem);

    break;

    } //if

    } //for

    } //for

    }

    All the rest I tried to no avail. Either it would throw JS errors on resizing or wouldn't simply work at all.

    Thanks for the help.

  • NVP Profile Picture
    150 on at

    I have the same requirement too and the following works for me to hide the button.

    button.style.visibility = 'hidden';

  • Community Member Profile Picture
    on at

    And are you calling the button by title or by id?

    Cause as I mentioned the Id is dynamic so I had to do it by title.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans