locked
Imp : Hide "Activate" and "DeActivate" menu items on "Actions" Menu on Main Page of Entity. RRS feed

  • Question

  • Dear Team,
        I have a entity "Booking". On the Main Page of CRM, when we click this Entity , we will get all the Active Bookings.
    On this page, there is one "Actions" Menu. On "Actions" Menu, we have DeActivate and Activate Menu Items.
    I want to hide this menu items for all users for this Entity only because I have my own logic written for Activation and DeActivation of this entity records and I have placed 2 buttons on the toolbar for this inside the Entity Form.

    What should I do for it and where should I write the javascript code because this is the main page and we do not have "onload" event for the main page for any Entity.

    Thanks and Regards,
    Abbas

    Thursday, August 6, 2009 7:45 AM

Answers

  • on your entity settings there should be messages
    look at what messages are dispalyed and remove the values.(always make a backup of your customizations)

    If the button is on your screen like Add New or Add Existing use the code below.
    On the last line be sure you use the excat name of the button.

    Onload:
    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);
    }
    }
    }



    /* Used internally by the 'HideAssociatedViewButtons' method */
    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++)
    {
    buttonTitleParts = buttonTitles[j].split('::');
    if (buttonTitleParts.length > 0)
    {
    buttonTitle = buttonTitleParts[0];
    for (var i = 0; i < liElements.length; i++)
    {
    liElement = liElements[i];
    if (liElement.getAttribute('title') == buttonTitle)
    {
    if (buttonTitleParts.length == 1)
    {
    liElement.style.display = 'none';
    break;
    }
    else
    {
    /* We want to hide a menu item in a drop-down menu.
    Find the descendant text element with the specified text.
    Then find its parent list item and hide it:
    */
    menuText = buttonTitleParts[1];
    var spanElements = liElement.getElementsByTagName('span');

    for (var k = 0; k < spanElements.length; k++)
    {
    spanElement = spanElements[k];
    if (spanElement.className == 'ms-crm-MenuItem-Text' )
    {
    textElement = spanElement.firstChild;
    if (textElement != null && textElement.nodeType == 3) /* 3 = Node.TEXT_NODE */
    {
    if (textElement.data == menuText)
    {
    liMenuItemElement
    = spanElement.parentNode.parentNode.parentNode;
    liMenuItemElement.style.display = 'none';
    break;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }


    HideAssociatedViewButtons("CRM_RELATION_SHIP", ["Add existing XXXX to this record", "Add a new XXXX to this record"]);

    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Tuesday, August 18, 2009 10:19 AM

All replies

  • Abbas,

    The Action button which you mention is on CRM grid which displays all the reocords related to particular entity in your case it is "Booking". Unfortunately we don't have any supported way to customize the grid items in CRM. 

    Let me know if you require further info.

    Regards,
    Amol 
    Jai Ho CRM http://mscrmkb.blogspot.com Skype - amol.gholap
    Thursday, August 6, 2009 8:18 AM
  • look at the ISVCONFIG.xml export file.
    On my blog should be examples hidding it through some jscript
    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Thursday, August 6, 2009 8:54 AM
  • Dear Sir,

    Can you please explain me the exact steps that I should follow to hide Activate and DeActivate buttons in CRM Grid?

    Thanks,
    Abbas
    Thursday, August 13, 2009 6:09 AM
  • I have gone through your blog, but didn't find any article related to hiding Activate and DeActivate buttons in CRMGrid.

    Please specify what to do?
    Tuesday, August 18, 2009 10:09 AM
  • on your entity settings there should be messages
    look at what messages are dispalyed and remove the values.(always make a backup of your customizations)

    If the button is on your screen like Add New or Add Existing use the code below.
    On the last line be sure you use the excat name of the button.

    Onload:
    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);
    }
    }
    }



    /* Used internally by the 'HideAssociatedViewButtons' method */
    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++)
    {
    buttonTitleParts = buttonTitles[j].split('::');
    if (buttonTitleParts.length > 0)
    {
    buttonTitle = buttonTitleParts[0];
    for (var i = 0; i < liElements.length; i++)
    {
    liElement = liElements[i];
    if (liElement.getAttribute('title') == buttonTitle)
    {
    if (buttonTitleParts.length == 1)
    {
    liElement.style.display = 'none';
    break;
    }
    else
    {
    /* We want to hide a menu item in a drop-down menu.
    Find the descendant text element with the specified text.
    Then find its parent list item and hide it:
    */
    menuText = buttonTitleParts[1];
    var spanElements = liElement.getElementsByTagName('span');

    for (var k = 0; k < spanElements.length; k++)
    {
    spanElement = spanElements[k];
    if (spanElement.className == 'ms-crm-MenuItem-Text' )
    {
    textElement = spanElement.firstChild;
    if (textElement != null && textElement.nodeType == 3) /* 3 = Node.TEXT_NODE */
    {
    if (textElement.data == menuText)
    {
    liMenuItemElement
    = spanElement.parentNode.parentNode.parentNode;
    liMenuItemElement.style.display = 'none';
    break;
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }
    }


    HideAssociatedViewButtons("CRM_RELATION_SHIP", ["Add existing XXXX to this record", "Add a new XXXX to this record"]);

    Tiaan van Niekerk http://crmdelacreme.blogspot.com Skype:tiaan.van.niekerk1
    Tuesday, August 18, 2009 10:19 AM
  • HI
    How can i find the entity settings could you give some more details for the same.
    Thanks in Advance.
    Thursday, August 11, 2011 5:34 AM
  • Hi

    Please be sure that if it is possible or not because we haven't find any messages for custom entity and there is no message which was showing when i click activate for the inbuilt entities present in the messages of the entity customization.

    Thursday, August 11, 2011 6:21 AM
  • Here's a way to accomplish this : http://blog.customereffective.com/blog/2012/05/managing-activatedeactivate-permissions-of-crm-entities.html

    Scott Sewell, CustomerEffective | http:\\blog.CustomerEffective.com | Twitter:@ScottSewell

    Tuesday, June 5, 2012 6:51 PM
    Moderator