根据CRM 2011中另一个字段的值禁用Tab

Disable Tab on the basis of value of another field in CRM 2011

本文关键字:Tab 字段 CRM 2011 另一个 根据      更新时间:2023-09-26

我正试图根据另一个字段(两个选项集)的值禁用选项卡。基本上我的目标是,如果过程完成=假,那么标签销售过程必须被禁用。如果流程完成=True,则必须启用标签销售流程。Process complete是一个两个选项集字段,Sales Process是一个选项卡。我使用下面的代码禁用选项卡中的所有控件。但我不能使它与另一个字段的条件(两个选项集)

function DisableAllControlsInTab(tabControlNo)
{
    var factfindcontrol=Xrm.Page.getAttribute("processcomplete").getValue();   
      var tabControl = Xrm.Page.ui.tabs.get("sales process");
   if (factfindcontrol ==false);
    if (tabControl != null) {
      Xrm.Page.ui.controls.forEach(
        function (control, index) {
        if (control.getParent().getParent() == tabControl && control.getControlType() != "subgrid")  {
            control.setDisabled(true);
        }
else {
control.setDisabled(false);
}
    });
    }
}

我终于算出来了

function DisableAllControlsInTab(tabControlNo)
{
    var factfindcontrol=Xrm.Page.getAttribute("processcomplete").getValue();   
      var tabControl = Xrm.Page.ui.tabs.get("salesprocess");
   if ((factfindcontrol ==0) &&
    (tabControl != null)) {
      Xrm.Page.ui.controls.forEach(
        function (control, index) {
        if (control.getParent().getParent() == tabControl && control.getControlType() != "subgrid")  {
            control.setDisabled(true);
        }
    });
    }
else {
Xrm.Page.ui.controls.forEach(
        function (control, index) {
        if (control.getParent().getParent() == tabControl && control.getControlType() != "subgrid")  {
            control.setDisabled(false);
}
});
}

}