如何使用自定义逻辑以 CRM 2011 中支持的方式有条件地在类似网格视图的场景中显示功能区组?
我修改了 CRM 2011 解决方案的站点地图以包含新区域。该区域包含一个组,该组包含一个子区域。
子区域是用类似于此的 URL 属性定义的...
<SubArea Id="x" Url="/WebResources/new_/y.html"
<Titles>
<Title Title="z" LCID="1033" />
</Titles>
</SubArea>
当用户单击导航栏中的此子区域时,y.html Web 资源将按预期加载到 CRM 的内容区域中。它的加载方式与网格视图的加载方式类似,但加载的不是网格视图,而是 y.html。
此外,还加载了定制的色带。
目前,此自定义功能区根据当前用户的角色禁用功能区按钮组。这是使用 RibbonDiffXml 中 CommandDefinition 的 EnableRule 来完成的。在 EnableRule 中定义了一个 CustomRule,它引用一个 javascript 函数,该函数根据有关用户角色的某些自定义逻辑返回 true 或 false。
这运作良好。但是,我被要求删除功能区按钮组,而不是仅仅隐藏它们。
我的理解是,这更多的是 DisplayRule 的任务,而不是启用规则。但是,据我收集的信息 DisplayRule 没有 CustomRule 选项,因为 < a href="http://msdn.microsoft.com/en-us/library/gg328073.aspx" rel="nofollow">EnableRule 可以。
在了解到 DisplayRule 不是一个选项后,我认为我可以在启用规则中编写一些 javascript 来删除该组(以及返回一个值来启用或不启用它)。但是,在调试 javascript 后,我发现虽然我可以访问 Xrm.Page,但无法访问 Xrm.Page.ui(类似于网格视图的预期结果)。因此,我也无法禁用此处的选项卡(不诉诸不受支持的 JavaScript)。
如何使用自定义逻辑以受支持的方式(例如,无 jQuery/ect)有条件地在类似网格视图的场景中显示功能区组?
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)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您基本上希望根据用户的权限切换功能区功能。
正确
不确定这是否一定正确。虽然
DisplayRule
可能没有CustomRule
选项,但它确实有一个杂项特权规则
。根据您的角色配置和您的要求,您也许能够绕过查看用户“角色”,而是设置一个有效检查的规则:如果用户可以读取发票实体,则显示此按钮(组)(显然这只是一个例子 - 你明白了)...
如果你的角色更复杂,你可以创建一个伪实体(例如称为“CanViewMySpecialButtons”),将其从 UI 中的任何位置删除并且仅向以下角色授予读取权限应该查看您的按钮。然后,您可以创建一个
MiscellaneousPrivilegeRule
来检查用户是否可以读取您的伪实体 - 只有您角色中的用户才能看到该实体,因此可以将该按钮设置为对所有其他用户隐藏。I assume then that you basically wish to toggle ribbon functionality, based on user's permissions.
Correct
Not sure that this is necessarily true. While
DisplayRule
may not have aCustomRule
option, it does have aMiscellaneousPrivilegeRule
.Depending on the configuration of your roles and your requirements, you may be able to bypass looking at the users "role" and instead set up a rule that effectively checks: if the user can read the invoice entity, show this button (group) (obviously this is just an example - you get the idea)...
If your roles are more complex you could create a pseudo-entity (e.g. called "CanViewMySpecialButtons"), remove it from anywhere in the UI and only grant read permissions to the roles that should view your buttons. You can then create a
MiscellaneousPrivilegeRule
that checks if the user can read your pseudo-entity - only those users in your role are able to see that entity therefore the button can be set hidden for all other users.