记录的按钮没有隐藏但是不能点击,xrm workbench

Button on record is not hidden but can't be clicked, xrm workbench

所以我在记录子网格中添加了关于按钮的规则,所以当满足条件时它将 return false 并且应该隐藏按钮。该脚本正在运行,但它没有隐藏按钮,而是使按钮被禁用(无法单击)。我错过了什么吗?以前从未使用过 xrm ribbon workbench。

下面是我的脚本:

function validatebuttondelete()
{
  var entityName = Xrm.Page.data.entity.getEntityName();

  if(entityName == "msdyn_workorder")
  {
    if(Xrm.Page.ui.getFormType() != 1)
    {
       var received = Xrm.Page.getAttribute("mjt_received").getValue()
       var receivedSp = Xrm.Page.getAttribute("mjt_received_sp").getValue()
       var stageName = Xrm.Page.data.process.getActiveStage().getName();

       if(stageName == "Branch")
       {
         if(received == 0)
         {
           return false;
         }
         else
         {
           return true;
         }
       }

       if(stageName == "Service Point")
       {
         if(receivedSp == 0)
         {
           return false;
         }
         else
         {
           return true;
         }
       }
     }
   }
}

您可以阅读启用规则和显示规则

要完全隐藏子网格中的删除按钮(垃圾桶 can/dustbin 图标)- 您只需右键单击并“隐藏”它即可。 Read more

但是你的要求稍微复杂一点。必须根据某些规则隐藏。至少对你来说它被禁用了。很多人都尝试过并最终以简单的警告消息结束,因为按钮不配合。

Reference

the (missing: Enable rule) did not hide the delete button, but allowed us to prevent the Delete action for the disabled records. We went ahead and unhid the Delete button, and then selected the Customize Command option. This populated the Mscrm.DeleteSelectedRecord command under the Command in Ribbon Workbench. We added another Enable rule called RestrictDeleteFromSubgrid