I've modified the sitemap of a CRM 2011 solution to contain a new Area. That area contians a single Group and the Group contains a single SubArea.
The SubArea is defined with a URL attribute similar to this...
<SubArea Id="x" Url="/WebResources/new_/y.html"
<Titles>
<Title Title="z" LCID="1033" />
</Titles>
</SubArea>
When a user clicks on this subarea in the nav bar the y.html webresource loads in the content area of CRM as expected. It loads similar to how a grid view would load, but instead of the grid view, y.html is loaded.
In addition, a customized ribbon is loaded.
Currently this customized ribbon disables ribbon button groups based on the role of the current user. This is done using an EnableRule of the CommandDefinition in RibbonDiffXml. In the EnableRule a CustomRule is defined that references a javascript function that returns true or false based on some custom logic regarding the users role.
This is working well. However, I've been asked to remove the ribbon button groups instead of just hiding them.
My understanding is that this is more of a task for a DisplayRule than an enable rule. However, from what I gather DisplayRule does not have a CustomRule option as EnableRule does.
After gathering that DisplayRule isn't an option, I thought that I might be able to write some javascript in the Enable rule to remove the group (as well as return a value to enable it or not). However, after debugging the javascript, I see that although I have access to Xrm.Page, I do not have access to Xrm.Page.ui (similar to the expected result for a grid view). Therefore, I can't disable the tab here either (without resorting to unsupported javascript).
How can I use custom logic to conditionally display a ribbon group in a grid view-like scenario in a supported fashion (e.g. no jQuery/ect)?
tabs
collection inXrm.Page.ui
refers to the navigation in the main part of an entity form, so you wouldn't be able to change the ribbon that way either. The best you can do withXrm.Page
is call therefreshRibbon
method, but that wouldn't affect the visibility of the ribbons anyway. – Peter Majeed