无法更新 Acumatica 中 SOLine 中扩展字段的值

Unable to update value for extension field in SOLine in Acumatica

我有一个针对 SOOrder.RowPersisting 的自定义代码 运行ning。 在该代码中,我 运行 遍历行并需要更新行上的扩展字段。

我无法将更改保存到数据库。

下面是部分示例代码:

    public class SOOrderEntry_Extension : PXGraphExtension<SOOrderEntry>
    {

        public PXSelect<SOLine,
            Where<SOLine.orderNbr, Equal<Required<SOLine.orderNbr>>,
            And<SOLine.orderType, Equal<Required<SOLine.orderType>>>>>
            SOLines;

        protected void _(Events.RowPersisting<SOOrder> e)
        {
            var sOOrder = e.Row;
            if (sOOrder == null) return;


            //Cycle through the items and expand any kits
            PXResultset<SOLine> lines = SOLines.Select(sOOrder.OrderNbr, sOOrder.OrderType);

            foreach (PXResult<SOLine> lineSet in lines)
            {
                SOLine line = (SOLine)lineSet;
                MAESxSOLine lineExt = PXCache<SOLine>.GetExtension<MAESxSOLine>(line);

                lineExt.UsrKitProcessed = true;
                SOLines.Cache.IsDirty = true;
                SOLines.Cache.Update(line);
                SOLines.Cache.Update(lineExt);
                SOLines.Cache.SetValueExt<MAESxSOLine.usrKitProcessed>(lineExt.UsrKitProcessed, true);
                        
                SOLines.Cache.Persist(PXDBOperation.Update);


如您所见,我尝试了很多不同的方法来设置扩展字段 UserKitProcessed。它将它设置在缓存中,但似乎不会持久保存到数据库中。

有什么想法吗?我有点生气:)

此致,

谢恩

而不是

SOLines.Cache.SetValueExt<MAESxSOLine.usrKitProcessed>(lineExt.UsrKitProcessed, true);

使用

SOLines.Cache.SetValueExt<MAESxSOLine.usrKitProcessed>(line, true);

SetValueExt 需要 SOLine 对象,而不是扩展名或 属性。那一定是把事情搞砸了。

所以整个操作是:

SOLines.Cache.SetValueExt<MAESxSOLine.usrKitProcessed>(line, true);
SOLines.Cache.Update(line);
SOLines.Cache.Persist(PXDBOperation.Update);