【问题标题】:How to add custom business logic to Acumatica framework's Actions?如何将自定义业务逻辑添加到 Acumatica 框架的 Actions?
【发布时间】:2016-08-29 16:59:03
【问题描述】:

我向 SOSshipment 添加了一个自定义字段,并且我想在 Order Entry 或通过 Process Orders 屏幕调用 CreateShipment 操作时设置其值。我该怎么做?

【问题讨论】:

    标签: acumatica


    【解决方案1】:

    为 SOOrderEntry 创建一个图形扩展并添加一个 Action 方法,如下所示:

    using PX.Data;
    using System.Collections;
    
    namespace PX.Objects.SO
    {
    
        public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
        {
            public PXAction<SOOrder> action;
            [PXUIField(DisplayName = "Actions", MapEnableRights = PXCacheRights.Select)]
            [PXButton]
            protected virtual IEnumerable Action(PXAdapter adapter,
                [PXInt]
                [PXIntList(new int[] { 1, 2, 3, 4, 5 }, new string[] { "Create Shipment", "Apply Assignment Rules", "Create Invoice", "Post Invoice to IN", "Create Purchase Order" })]
                int? actionID,
                [PXDate]
                DateTime? shipDate,
                [PXSelector(typeof(INSite.siteCD))]         
                string siteCD,
                [SOOperation.List]
                string operation,
                [PXString()]
                string ActionName)
            {
                //actionID = 1 means the CreateShipment action was the one invoked
                if (actionID == 1)
                {
                    PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graph) =>
                    {
                        graph.RowInserting.AddHandler<SOShipment>((sender, e) =>
                        {
                            //Custom logic goes here
                            var shipment = (SOShipment)e.Row;
                            var shipmentExt = PXCache<SOShipment>.GetExtension<SOShipmentExt>(shipment);
                            if (Base.Document.Current != null && shipmentExt != null)
                            {
                                shipmentExt.UsrPriority = Base.Document.Current.Priority;
                            }
                        });
                    });
                }
    
                //calls the basic action that was invoked
                return Base.action.Press(adapter);
            }
        }
    }
    

    当 SOOrderEntry 的任何操作运行时(甚至通过“处理订单”屏幕),都会调用此方法。我们使用actionID == 1 验证该操作确实是 CreateShipment,并为 SOShipmentEntry 图创建和 SOShipment RowInserting 添加事件处理程序。我们的自定义逻辑被添加到 RowInserting 事件中。

    【讨论】:

    猜你喜欢
    • 2011-02-19
    • 2015-07-23
    • 2017-11-18
    • 1970-01-01
    • 2011-04-15
    • 2016-08-04
    • 2021-04-11
    • 1970-01-01
    • 2013-09-14
    相关资源
    最近更新 更多