Acumatica 无法在创建装运操作中将UDF从SOLine(SO301000)复制到SOShipLine(SO302000)

Acumatica 无法在创建装运操作中将UDF从SOLine(SO301000)复制到SOShipLine(SO302000),acumatica,acumatica-kb,Acumatica,Acumatica Kb,我在SOLine和SOShipLine中创建了2个UDF,我正在尝试在创建装运操作中将这些UDF的值从SOLine复制到SOShipLine。我的代码正在执行,但值没有被复制。我不确定SouRowPersisting是否是一种正确的方法,或者是否有其他方法可以解决这个问题。虽然这种划行方式在将字段从POOrder复制到APInvoice时对我有效,但请建议,谢谢 以下是我的代码: public class SOShipmentEntry_Extension : PXGraphExtension&

我在SOLine和SOShipLine中创建了2个UDF,我正在尝试在创建装运操作中将这些UDF的值从SOLine复制到SOShipLine。我的代码正在执行,但值没有被复制。我不确定SouRowPersisting是否是一种正确的方法,或者是否有其他方法可以解决这个问题。虽然这种划行方式在将字段从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;
                }

            }
        }
}

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

在您的情况下,您可以覆盖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,这很好,谢谢你警告不要使用文档事件。请您帮助我使用创建装运操作将自定义项从POLine PO301000复制到POReceiptLine PO302000。我会感谢你的。谢谢