Acumatica 保存记录时插入网格线

Acumatica 保存记录时插入网格线,acumatica,Acumatica,我试图在持久化逻辑期间向网格添加一条新记录。但是,即使记录确实添加到UI中的网格中,当页面刷新时,新行也会消失。它没有在数据库中持久化 我正在使用账单页面作为参考 代码示例 protected virtual void APTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e) { if (e.Row == null) { return; } APInvoice invoice

我试图在持久化逻辑期间向网格添加一条新记录。但是,即使记录确实添加到UI中的网格中,当页面刷新时,新行也会消失。它没有在数据库中持久化

我正在使用账单页面作为参考

代码示例

protected virtual void APTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
{
    if (e.Row == null)
    {
        return;
    }

    APInvoice invoiceRow = this.Base.Document.Current;

    if (invoiceRow != null)
    {

        APTran tranRow = new APTran();
        tranRow = this.Base.Transactions.Insert(tranRow);

        tranRow.InventoryID = 10043;
        this.Base.Transactions.Update(tranRow);

        tranRow.Qty = 3;
        this.Base.Transactions.Update(tranRow);
    }
}
保存后的结果-记录显示在网格中:

取消后的结果-记录从网格中消失:

类似于此,我倾向于重写Persist方法,并在调用base Persist之前插入或更新相关记录。以下是图形扩展中的一个可能示例:

[PXOverride]
public virtual void Persist(Action del)
{
    foreach(APInvoice invoiceRow in Base.Document.Cache.Inserted)
    {
        APTran tranRow = this.Base.Transactions.Insert();

        tranRow.InventoryID = 10043;
        tranRow = this.Base.Transactions.Update(tranRow);

        tranRow.Qty = 3;
        this.Base.Transactions.Update(tranRow);
    }

    del?.Invoke();
}