【问题标题】:View.Ask in action causes the message box to display repeatedlyView.Ask in action 导致消息框重复显示
【发布时间】:2021-12-14 17:58:39
【问题描述】:

我有以下代码来覆盖采购订单条目屏幕上的“电子邮件采购订单”操作。

代码编译并显示消息,但在选择是或否后,消息会一次又一次地显示,直到我单击 X。知道什么会导致这种情况吗?

public delegate IEnumerable NotificationDelegate(PXAdapter adapter, String notificationCD);

[PXOverride]
public IEnumerable Notification(PXAdapter adapter, String notificationCD, NotificationDelegate baseMethod)
  {
    if(Base.Document.Ask("Are you sure you want to Email the PO?", MessageButtons.YesNo)
           != WebDialogResult.Yes) return adapter.Get();
          
    return baseMethod(adapter, notificationCD);
    
    
  }

更新:

这是我最近的尝试,但仍然无法正常工作。代码编译,但我从来没有得到消息框。添加了一条跟踪消息以确认它正在命中代码:

public PXAction<POOrder> notification;

[PXUIField(DisplayName = "Notifications", Visible = false)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
protected virtual IEnumerable Notification(PXAdapter adapter,
    [PXString] string notificationCD)
{
    PXTrace.WriteInformation("Reached Notification Action - Notification CD = " + notificationCD + '|');
  
    if (notificationCD == "PURCHASE ORDER")
    {
      PXTrace.WriteInformation("Notification Action - If reached");
      
         if(Base.Document.Ask("Are you sure you want to Email the PO?", MessageButtons.YesNo)
   != WebDialogResult.Yes) return adapter.Get();  
    }


      return Base.notification.Press(adapter);
    
}        

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    如果消息对话框请求位于框架无法处理消息框的位置,则会发生这种情况。

    尝试覆盖操作本身 (21R1):

        public PXAction<POOrder> emailPurchaseOrder;
        [PXButton(CommitChanges = true)]
        [PXUIField(DisplayName = "Email Purchase Order", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
        public virtual IEnumerable EmailPurchaseOrder(
            PXAdapter adapter, 
            [PXString] 
            string notificationCD = null)
        {
                 if(Base.Document.Ask("Are you sure you want to Email the PO?", MessageButtons.YesNo)
           != WebDialogResult.Yes) return adapter.Get();  
             return Base.emailPurchaseOrder.Press(adapter);
        }
    

    或者对于 20R2

        public PXAction<POOrder> notification;
    
        [PXUIField(DisplayName = "Notifications", Visible = false)]
        [PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntryF)]
        protected virtual IEnumerable Notification(PXAdapter adapter,
            [PXString] string notificationCD)
        {
            if (notificationCD == "EM")
            {
                 if(Base.Document.Ask("Are you sure you want to Email the PO?", MessageButtons.YesNo)
           != WebDialogResult.Yes) return adapter.Get();  
            }
    
              return Base.emailPurchaseOrder.Press(adapter);
            
        }
    

    【讨论】:

    • 嗨凯尔,感谢您的回复。我首先尝试覆盖 Notification 操作,但由于基本方法受到保护而收到错误消息。我在表单的代码中没有看到名为 emailPurchaseOrder 的操作,我会试试你的代码。再次感谢
    • 我收到以下代码编译错误。 “POOrderEntry”不包含“emailPurchaseOrder”的定义,并且找不到接受“POOrderEntry”类型的第一个参数的可访问扩展方法“emailPurchaseOrder”
    • 这是什么版本的 Acumatica?
    • 构建 20.216.0024
    • 知道了,我发了我的代码sn-p for 2021R1,我在原帖里加了20 r2
    猜你喜欢
    • 2011-04-24
    • 2011-12-07
    • 2011-04-11
    • 2013-10-28
    • 2014-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    相关资源
    最近更新 更多