How to disable a Ribbon group based on the form attribute value? RRS feed

  • Question

  • Hi All,

    I want to disable Ribbon group based on stateCode value.

    I have a an entity 'My Entity' having 1:n relationship with Call.When the Call is resolved and if I go to associated view of this entity('My Entity') from Call entity left navigation pane. I am still able to delete or Edit this enity from this entity's ribbon.

    How can I disable the entity's group(Records)on the ribbon?

    Pls help me out.



    Monday, June 4, 2012 2:17 PM

All replies

  • Hi Mohammad Yusuf,

    Try the following javascript code. You can write similar javascript for disable ribbon.


            if (Xrm.Page.getAttribute('statuscode').getSelectedOption().value == 1) {

                  window.setInterval("OnLoadOfRibbon(2)", 20);
            else {
              window.setInterval("OnLoadOfRibbon(1)", 20);

    function OnLoadOfRibbon(value) {
        var CampaignActivityPropogate = window.top.document.getElementById("campaignactivity|NoRelationship|Form|Mscrm.Form.campaignactivity.CampaignActivityPropogate-Large");

        if (value == 1) {
            CampaignActivityPropogate.style.display = 'none';
        else if (value == 2) {
            CampaignActivityPropogate.style.display = 'inline';

    • Proposed as answer by Ercan Top Monday, June 4, 2012 8:28 PM
    • Edited by Ercan Top Monday, June 4, 2012 8:28 PM
    Monday, June 4, 2012 8:22 PM
  • You could write some JS to check the statecode and return true or false. Then you can set a DisplayRule on the ribbon group in Visual Ribbon Editor.

    Tuesday, June 5, 2012 9:38 AM