locked
How to toggle visibility between two ribbon button in MSD CRM 2011 RRS feed

  • Question

  • Hi,

    I have two Ribbon Button's " Execute" and "Remove Execute" . I want to enable "Execute" button on selection of radio button click "Yes" and disable button "Remove Execute"button , When user select value "No" from radio button then Enable "Remove Execute" button and disable "Execute" Button.

    How can i toggle these two button's visisbility depending  on selection value of radio button.

    However i can enable /disable button using enable rule for single button, How can i handle visibility of both button using same control (radio button) in Dynamic crm 2011 MS supported way.

    Wednesday, December 26, 2012 1:33 PM

Answers

  • Hi,
        You can use two DisplayRules(DisplayRule->ValueRule) which are specific to each ribbon button. Instead of manually editing the ribbon xml, you can use Ribbon Work Bench to do that.

            <DisplayRule Id="Mscrm.Form.contact.Execute">
              <ValueRule Field="new_radiobutton" Value="1" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.Form.contact.RemoveExecute">
              <ValueRule Field="new_radiobutton" Value="0" />
            </DisplayRule>


    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"

    Wednesday, December 26, 2012 1:53 PM
  • you can disable this through javascript also

    var saveID = "new_test|NoRelationship|Form|Mscrm.Form.new_test.Save-Large"; // id of ribbon button
    var saveandcloseid="new_test|NoRelationship|Form|Mscrm.Form.new_test.SaveAndClose-Large";
    var save = window.top.document.getElementById(saveID);
    var saveandclose = window.top.document.getElementById(saveandcloseid);

       save.disabled = true;
       saveandclose.disabled=true;

    above is sample to disable the ribbon button (save and saveclose)


    ms crm

    Wednesday, December 26, 2012 3:50 PM

All replies

  • Hi,
        You can use two DisplayRules(DisplayRule->ValueRule) which are specific to each ribbon button. Instead of manually editing the ribbon xml, you can use Ribbon Work Bench to do that.

            <DisplayRule Id="Mscrm.Form.contact.Execute">
              <ValueRule Field="new_radiobutton" Value="1" />
            </DisplayRule>
            <DisplayRule Id="Mscrm.Form.contact.RemoveExecute">
              <ValueRule Field="new_radiobutton" Value="0" />
            </DisplayRule>


    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"

    Wednesday, December 26, 2012 1:53 PM
  • you can disable this through javascript also

    var saveID = "new_test|NoRelationship|Form|Mscrm.Form.new_test.Save-Large"; // id of ribbon button
    var saveandcloseid="new_test|NoRelationship|Form|Mscrm.Form.new_test.SaveAndClose-Large";
    var save = window.top.document.getElementById(saveID);
    var saveandclose = window.top.document.getElementById(saveandcloseid);

       save.disabled = true;
       saveandclose.disabled=true;

    above is sample to disable the ribbon button (save and saveclose)


    ms crm

    Wednesday, December 26, 2012 3:50 PM
  • Hello,

    you need to use Enable rule for this you can see one example here in msdn, you can apply value rule for this

    HTH


    Contact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, December 27, 2012 5:16 AM
    Moderator
  • Hi All,

    1] Display rule works fine , but onchange of radio button this toggling is not handling .It works when ribbon get refresh on events(Save etc) but not on on change of radio button , i tried using refreshing ribbon (Xrm.Page.ui.refreshRibbon()) on change event , however rule is not firing on change .

    2] Incase of Enable rule we can  use above "value rule" method ,but both buttons get disable whenever page load. If we right custom rule ,which checks the status of radio button event and enable /disable accordingly ,but this works only for single button.second button doen't get toggle accordingly.

    3] Button can be disable by getting buttonid and writing disable js on form load ,but here image associated with button not getting

    disable ?

    function Test()
    {
    var status = Xrm.Page.getAttribute("new_escalaterequest").getValue();
    alert(status);
    if (status==1)
    {
    return true;
    }
    else
    {
    return false;
    }

    }


    Prashanth M..J



    Thursday, December 27, 2012 8:29 AM
  • This works fine for all conditions.

    Button can be disable by getting buttonid and writing disable js on form load ,but here image associated with button not getting disable ?

    Thanks Dicaprio


    Prashanth M..J


    Thursday, December 27, 2012 8:31 AM