【问题标题】:How to update a custom field values while confirm shipment action is running in Acumatica如何在 Acumatica 中运行确认装运操作时更新自定义字段值
【发布时间】:2020-05-18 18:45:01
【问题描述】:

我们需要为某些业务工作复制确认发货操作按钮,并且还需要在确认发货长期操作完成时更新一些自定义字段。

以下是我的代码,但在进行缓存更新时出现错误:集合已修改;枚举操作可能无法执行。

请指正我做错的地方

public PXAction<PX.Objects.SO.SOShipment> ConfirmShipment;
        [PXUIField(DisplayName = "Confirm Shipment")]
        [PXButton]
        protected virtual IEnumerable confirmShipment(PXAdapter adapter)
        {
            if (ShipFilter.Current != null)
            {
                var soOrderShip = Base.Document.Current;
                if (soOrderShip != null)
                {
                    var graph = PXGraph.CreateInstance<SOShipmentEntry>();
                    //We are recreating an adapter like the framework would do.
                    var a = new PXAdapter(graph.Document)
                    {
                        Searches = new object[] { soOrderShip.ShipmentNbr }
                    };
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        //Note: Confirm Shipment is Action 1 : 
                        a.Arguments.Add("actionID", 1);
                        PXLongOperation.StartOperation(Base, () => { foreach (SOShipment soShipment in graph.action.Press(a)) ; });
                        //PXLongOperation.WaitCompletion(graph.UID);
                        PXAutomation.CompleteAction(graph);
                        PXLongOperation.WaitCompletion(graph.UID);
                        PXLongOperation.ClearStatus(graph.UID);
                        graph.Document.Cache.SetValueExt<SOShipmentExt.usrKWMXDCTimeStamp>(soOrderShip, Convert.ToDateTime(Convert.ToDateTime(new PX.Data.PXGraph().Accessinfo.BusinessDate).ToShortDateString() + " " + PX.Common.PXTimeZoneInfo.Now.ToLongTimeString()));
                        graph.Document.Cache.SetValueExt<SOShipmentExt.usrKWMXPieceCount>(soOrderShip, Convert.ToDecimal(Base.Document.Current.ShipmentQty));
                        graph.Document.Cache.SetValueExt<SOShipmentExt.usrKWMXEnteredBy>(soOrderShip, this.ShipFilter.Current.EnteredBy);
                        graph.Document.Update(soOrderShip);
                        graph.Save.Press();
                        ts.Complete();
                    }
                }
            }
            return adapter.Get();
        }

提前致谢。

【问题讨论】:

    标签: acumatica acumatica-kb


    【解决方案1】:

    您应该重写 Confirmation 例程,执行 Base 操作,然后添加您的代码。

    Extend existing event

    【讨论】:

    • 嗨,当我点击我的新自定义按钮(如上面的代码所示)时,覆盖 ConfirmShipment 并调用基本方法不起作用。当我单击“确认发货”下的“操作”时,正在执行覆盖功能。但在这里我不会点击那个按钮,我只是按下我的自定义操作按钮,在里面我正在调用确认发货操作
    • 阅读附加的堆栈答案,您会想要执行第二个策略。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-31
    • 1970-01-01
    • 2022-11-23
    • 2018-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多