【问题标题】:Unable to Copy UDF from SOLine (SO301000) to SOShipLine(SO302000) on Create Shipment Action创建装运操作时无法将 UDF 从 SOLine (SO301000) 复制到 SOShipLine(SO302000)
【发布时间】:2021-07-23 16:40:09
【问题描述】:

我在 SOLine 和 SOSshipLine 中创建了 2 个 UDF,我试图在“创建货件”操作中将这些 UDF 的值从 SOLine 复制到 SOShipLine。我的代码正在执行,但值没有被复制。我不确定“SOSshipment_RowPersisting”是否是正确的方法,或者是否有任何其他方法可以解决这个问题。尽管此 RowPersisting 对我将字段从 POOrder 复制到 APInvoice 有用,但请提出建议,谢谢

以下是我的代码:

public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>
  {
        #region Event Handlers
        protected void SOShipment_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var row = (SOShipment)e.Row;
            SOShipLine row1 = new SOShipLine();
            if (Base.Document.Current != null)
            {
                foreach (SOShipLine tran in Base.Transactions.Select())
                {
                    SOLine xSOLine = PXSelect<SOLine, 
                        Where<SOLine.orderNbr, Equal<Current<SOLine.orderNbr>>,
                        And<SOLine.orderType, Equal<Current<SOLine.orderType>>>>>.Select(Base, tran.OrigOrderNbr, tran.OrigOrderNbr);
                    if (xSOLine != null)
                    {
                        SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt>(xSOLine);
                        SOShipLineExt soShipLineExt = PXCache<SOShipLine>.GetExtension<SOShipLineExt>(row1);

                        soShipLineExt.UsrTerms = soLineExt.UsrTerms;
                        soShipLineExt.UsrWarrantyDate = soLineExt.UsrCustWarrDate;
                    }
                    return;
                }

            }
        }
}

【问题讨论】:

    标签: acumatica acumatica-kb


    【解决方案1】:

    当从一个文档复制到另一个文档时,我尽量远离文档事件,因为即使在文档创建之后它们也会被执行。因此,我总是在创建文档的过程中尝试挂钩一个方法。

    在您的情况下,您可以覆盖 SOShipmentEntry 图中的“CreateShipmentFromSchedules”方法并将您的代码移到那里。这将挂钩您的代码,以便仅在从 SO 转换为货件时执行。

    public delegate Boolean CreateShipmentFromSchedulesDelegate(PXResult<SOShipmentPlan, SOLineSplit, 
            SOLine, InventoryItem, INLotSerClass, INSite, SOShipLine> res, SOShipLine newline, SOOrderType ordertype, 
            String operation, DocumentList<SOShipment> list);
    
    [PXOverride]
    public Boolean CreateShipmentFromSchedules(PXResult<SOShipmentPlan, SOLineSplit, SOLine,
            InventoryItem, INLotSerClass, INSite, SOShipLine> res, SOShipLine newline, SOOrderType ordertype,
            String operation, DocumentList<SOShipment> list, CreateShipmentFromSchedulesDelegate baseMethod)
    {
        if (res != null && newline != null)
        {
                SOShipLineExt soShipLineExt = PXCache<SOShipLine>.GetExtension<SOShipLineExt>(newline);
                SOLine line = (SOLine)res;
                SOLineExt soLineExt = PXCache<SOLine>.GetExtension<SOLineExt >(line);
    
                soShipLineExt.UsrTerms = soLineExt.UsrTerms;
                soShipLineExt.UsrWarrantyDate = soLineExt.UsrCustWarrDate;
        }
    
        return baseMethod(res, newline, ordertype, operation, list);
    }
    

    【讨论】:

    • 感谢 Jean,这一切正常,感谢您警告不要使用文档事件。请您帮助我使用“创建货件”操作将 UDF 从 POLine (PO301000) 复制到 POReceiptLine (PO302000)。我会很感激你的。谢谢
    猜你喜欢
    • 1970-01-01
    • 2021-07-25
    • 1970-01-01
    • 2015-04-22
    • 1970-01-01
    • 2015-07-04
    • 1970-01-01
    • 1970-01-01
    • 2017-07-07
    相关资源
    最近更新 更多