最近项目中遇到这样的一个情况,ribbonButton会根据当前页面的字段操作来判断是否可用。通常情况是当操作完字段值 并点击保存页面会刷新重新加载,ribbonButton会基于字段值来判断是否可用。
但是在测试时,测试人员希望在操作完字段未点击Save按钮之前就控制ribbonButton是否可用。
以下给出解决方案:
refreshRibbon (Client API reference)
Applies to Dynamics 365 for Customer Engagement apps version 9.x
Causes the ribbon to re-evaluate data that controls what is displayed in it.
Syntax
formContext.ui.refreshRibbon(refreshAll);
Parameter
Name | Type | Required | Description |
---|---|---|---|
refreshAll | Boolean | No | Indicates whether all the ribbon command bars on the current page are refreshed. If you specify false, only the page-level ribbon command bar is refreshed. If you do not specify this parameter, by default false is passed. |
Remarks
This function is typically used when a ribbon (RibbonDiffXml) depends on a value in the form. After your code changes a value that is used by a rule, use this method to force the ribbon to re-evaluate the data in the form so that the rule can be applied.