locked
disable a subgrid ribbon button RRS feed

  • Question

  • Hi,

    Do  anyone know how to disable a ribbon button conditionally? The ribbon button belong to a grid in the entity form, which will be available upon selecting the grid. I am trying to disable "Add new quote" button in Opportunities form. But no luck with samples from internet. Please someone help me.
    Saturday, April 23, 2011 1:01 AM

Answers

  • Finally I was able to get things done.

    Following are steps I followed

    1. Get RibbonXML for entity for which customization is needed

    2. Copy Ribbon element for which behavior needs to be changed.

    3. Copy CommandDefinition for Ribbon Element which is copied in Step#2

    4. Export CRM entity customization for which changes is needed and open it in VSTS 2010.

    5. Under RibbonDiff.CustomAction copy Ribbon Element which is copied in step #2, important thing here is Location for CustomAction should exactly match with RibbonElementID

    6. Under CommandDefinitions copy CommandDefinition which is copied in step #2, change is Id and change command value of Ribbon Element to new CommandDefinition Id

    7. Now since we are having new Command Definition we can add our own DisplayRule, EnableRule etc

    8. Finally save and import Entity Customization

    Hope this helps


    makeer
    Monday, May 23, 2011 2:56 AM

All replies

  • Hi Ram_Tech,

    This can be done. Please check my blog post on this:

    http://howto-mscrm.blogspot.com/2011/04/how-to-series-6-how-to-overrideenable.html

    and also do check this blog post on how to use <CustomRule>

    http://howto-mscrm.blogspot.com/2011/04/how-to-series-6-how-to-use-customrule.html

    Hope it helps you.


    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
    Sunday, April 24, 2011 11:15 AM
  • Hi Vikranth,

    Thanks for the reply.

    I tried the same as in your blog, but no luck.

    I think i am choosing wrong button. I tried with lead entity.

    I attempted to disable new record button when Notes and Activities subgrid is selected.

    Below is my customaction tag. Please let me know if anything wrong in that.

    <CustomAction Id ="abc.Mscrm.SubGrid.lead.NewRecord.CustomAction.Id" Location ="Mscrm.SubGrid.lead.NewRecord" Sequence ="10">
                <CommandUIDefinition>
                  <Button Id="Mscrm.SubGrid.lead.NewRecord" ToolTipTitle="$Resources(EntityDisplayName):Ribbon.SubGrid.MainTab.New" ToolTipDescription="$Resources(EntityDisplayName):Ribbon.Tooltip.New" Command="abc.lead.Mscrm.NewRecordFromGrid.cmd" Sequence="10" LabelText="$Resources(EntityDisplayName):Ribbon.SubGrid.MainTab.New" Image16by16="/_imgs/ribbon/NewRecord_16.png" Image32by32="/_imgs/ribbon/newrecord32.png" TemplateAlias="o1" />
                </CommandUIDefinition>
              </CustomAction>

     

              <CommandDefinition Id="abc.lead.Mscrm.NewRecordFromGrid.cmd">
                <EnableRules>
                  <EnableRule Id ="abc.lead.addactivity.disable"/>
                </EnableRules>
                <DisplayRules />
                <Actions />
              </CommandDefinition>

                <EnableRule Id="abc.lead.addactivity.disable">
                  <CrmClientTypeRule Type ="Outlook"/>
                </EnableRule>
              </EnableRules>
    Tuesday, April 26, 2011 6:50 PM
  • Hi Ram_Tech,

    It seems you have selected the wrong button. Below is my understanding as per your query and the code written.
    Enable "Add New Activity" Flyout Anchor for "Lead" entity "Activity-Subgrid" in Outlook" client only and disable for the rest of the clients.
    If I am correct then below is approach to achieve it.
    Observation:
    When a user selects "Activities" Sub-grid in a "lead" form(or in any form), "Activities" Tab will be shown. This "Activities" tab is actually a "Contextual Tab" which is defined under "activitypointer" ribbon xml. So, if you are planning override this tab's behavior then we need to add "activitypointer" entity to our solution and modify respective "ContextualGroup". This modification will reflect "Activities" contextual tab for all entities. So, make sure that your modification won't reflect others.
    Approach:
    In your case, to enable/disable "Activities" Contextual tab we need consider the id Mscrm.SubGrid.activitypointer.NewActivitiesMenu in "activitypointer" entitiy's <RibbonDiffXml>. Use this Id and modify the "activity" entity's ribbon xml as mentioned in the blog article.
    <Groups Id="Mscrm.SubGrid.activitypointer.MainTab.Groups" ..........>
    <Group Id="Mscrm.SubGrid.activitypointer.MainTab.Management" ...............>
    <Controls Id="Mscrm.SubGrid.activitypointer.MainTab.Management.Controls">
    <FlyoutAnchor Id="Mscrm.SubGrid.activitypointer.NewActivitiesMenu" ................./>
    As I mentioned earlier, whatever the <EnableRule> we add/remove will effect all the entities which has 1-N relationship with "activity" entity. If you want to enable the ribbon item only for "Outlook" client then below <EnableRule> will do that for you.
    <CrmClientTypeRule Type="Outlook"/>
    Please let me know when(for which entities, which clients...etc) you want disable/enable the "Add Activity" item. Please let me know if I am getting your query wrong. Hope it helps you.

    Vikranth http://howto-mscrm.blogspot.com "Please Mark it as answer if it helps in resolving your query"
    Wednesday, April 27, 2011 9:04 AM
  • Dear Vikranth,

    Thanks for the reply.

    Ideally i wanted to control the AddNewQuote button in Opportunity window. If an active quote exists I should be able to disable the add New Quote button.

    For sample, to control the subgrid menu, I posted you with a lead sample.  Anways will try your sample and get back.

     

    Thanks

     

    Thursday, April 28, 2011 11:12 AM
  • Dear Vikranth,

    Thanks for your help. The problem is resolved. I was trying with different entity. After your post i realised that.

     For disabling" Add New Quote" button in Opportunity, I should do the ribbon customization in Quote entity.

    Earlier I tried with Opportunity entity. Now its fine. Thanks again.

    Thursday, April 28, 2011 4:27 PM
  • Hi,

    I was doing same mistake of modifying XML for Parent Entity in which SubGrid was shown. I havent tried rectifying it because I have few more doubts.

    I have following scenario,

    1 Parent Entity called Industry.

    2. In Header form I am having Entity "Verticals" shown as Sub-Grid

    Here is requirement

    1. Based on which IndustryId is opened, I wanted to do some JavaScript check using REST and decide whether to allow user to Add new Verticals.

    My Doubts:

    If in order to achieve above funtionality I have to make modification in VerticalRibbon.xml then would I be able to pass IndustryId to Javascript function because IndustryId is available on Indudtry Form and I would be making changes in VerticalRibbon XML

    Thanks


    makeer
    Wednesday, May 18, 2011 10:31 PM
  • Well, I just tried the solution but its not working :(

    I tried with simple Javascript function which returns false all the time. But that javascript function is not at all getting called.

    I guess I have to keep on trial-Err to see which changes clicks....

     

     


    makeer
    Wednesday, May 18, 2011 11:09 PM
  • Finally I was able to get things done.

    Following are steps I followed

    1. Get RibbonXML for entity for which customization is needed

    2. Copy Ribbon element for which behavior needs to be changed.

    3. Copy CommandDefinition for Ribbon Element which is copied in Step#2

    4. Export CRM entity customization for which changes is needed and open it in VSTS 2010.

    5. Under RibbonDiff.CustomAction copy Ribbon Element which is copied in step #2, important thing here is Location for CustomAction should exactly match with RibbonElementID

    6. Under CommandDefinitions copy CommandDefinition which is copied in step #2, change is Id and change command value of Ribbon Element to new CommandDefinition Id

    7. Now since we are having new Command Definition we can add our own DisplayRule, EnableRule etc

    8. Finally save and import Entity Customization

    Hope this helps


    makeer
    Monday, May 23, 2011 2:56 AM