单个字段值不会在缓存更新时更新 [英] Single field value won't update on cache update

查看:34
本文介绍了单个字段值不会在缓存更新时更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试插入一个 INKitRegister 项目.代码如下:

I'm attempting to insert an INKitRegister item. Here's the code:

KitAssemblyEntry kitGraph = CreateInstance<KitAssemblyEntry>();
INKitRegister kit = new INKitRegister();
kitGraph.Document.Current = kit;
kitGraph.Document.Cache.SetValueExt<INKitRegister.inventoryID>(kit, mixQLine.InventoryID);
// This line is not working 
kitGraph.Document.Cache.SetValueExt<INKitRegister.locationID>(kit, 
scales.LocationID);
kitGraph.Document.Cache.SetValueExt<INKitRegister.uOM>(kit, mixQLine.Uom);
kitGraph.Document.Cache.SetValueExt<INKitRegister.qty>(kit, mixQLine.Qty);
kit = kitGraph.Document.Cache.Update(kit) as INKitRegister;
kitGraph.Actions.PressSave();

如果我手动配置 InventoryItem 以分配默认位置,则该项目会正确插入所有其他字段,但如果没有,则会引发此错误:

If I manually configure the InventoryItem to have a default location assigned, the item inserts properly for all other fields, but if not, it throws this error:

错误:插入IN Kit Split"记录至少引发了一个错误.请检查错误.

Error: Inserting 'IN Kit Split' record raised at least one error. Please review the errors.

我做错了什么?

错误":

2020 年 9 月 11 日下午 2:36:26 错误:错误:插入IN Kit Split"记录引发了至少一个错误.请检查错误.在 PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache 发送方,PXCommandPreparingEventArgs e)at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description)在 PX.Data.PXProjectionAttribute.PersistInserted(PXCache 发送方,对象行)在 PX.Data.PXCache.PersistInserted(Object row, Boolean bypassInterceptor)在 PX.Data.PXCache.Persist(PXDBOperation 操作)在 PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation 操作)在 PX.Data.PXGraph.Persist()在 PX.Data.PXSave.d__2.MoveNext()在 PX.Data.PXAction.d__28.MoveNext()在 PX.Data.PXAction.d__28.MoveNext()在 PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] 降序, Object[] 搜索, Object[] 参数, PXFilterRow[] 过滤器, DataSourceSelectArguments 参数, Boolean& closeWindowRequired, Int32& adapterStartRow,Int32&adapterTotalRows)在 PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments)

9/11/2020 2:36:26 PM Error: Error: Inserting 'IN Kit Split' record raised at least one error. Please review the errors. at PX.Data.PXUIFieldAttribute.CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e) at PX.Data.PXCache.OnCommandPreparing(String name, Object row, Object value, PXDBOperation operation, Type table, FieldDescription& description) at PX.Data.PXProjectionAttribute.PersistInserted(PXCache sender, Object row) at PX.Data.PXCache.PersistInserted(Object row, Boolean bypassInterceptor) at PX.Data.PXCache.Persist(PXDBOperation operation) at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation) at PX.Data.PXGraph.Persist() at PX.Data.PXSave.d__2.MoveNext() at PX.Data.PXAction.d__28.MoveNext() at PX.Data.PXAction.d__28.MoveNext() at PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName, String[] sortcolumns, Boolean[] descendings, Object[] searches, Object[] parameters, PXFilterRow[] filters, DataSourceSelectArguments arguments, Boolean& closeWindowRequired, Int32& adapterStartRow, Int32& adapterTotalRows) at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName, DataSourceSelectArguments arguments, PXDSSelectArguments pxarguments)

推荐答案

SetValueExt 的使用看起来是正确的,前提是 mixQLine 和 scales 都是非空且引用的字段也非空.但是,您应该模拟插入"操作.按钮通过 Document.Insert(kit); 插入您的新 INKitRegister.有时,您需要在插入之前在记录中填写一些值(例如在销售订单中输入 SOType),但在大多数情况下我不需要这样做.如果您的记录存在,通常您会通过以下方式搜索记录:

The use of SetValueExt looks correct, provided mixQLine and scales are both non-null with the referenced fields also non-null. However, you should simulate the "Insert" button via Document.Insert(kit); to insert your new INKitRegister. Sometimes, you need to fill in a few values on the record (like on Sales Order entering SOType) before you insert, but in most cases I haven't needed to do so. If your record exists, typically you would search for the record via:

Document.Current = Document.Search<keyField>(keyValue);

在视图上使用 Insert 方法将确保在图表中触发所有正确事件的情况下创建记录.我最好的猜测是这是潜在的问题,尽管在设置某些字段之前您可能需要对缓存进行临时更新.(例如,如果位置与库存 ID 相关联,您可能需要使用库存 ID 更新缓存,以便 DAC 更新选择器并检索适用于该项目的位置.)

Use of the Insert method on the view will ensure the record is created with all the proper events firing in the graph. My best guess is that this is the underlying issue, although you may need an interim update on the cache before setting certain fields. (For instance, if the location is tied to the inventoryID, you likely need to update the cache with the inventoryID so that the DAC updates the selector and retrieves locations applicable to the item.)

未经测试,但我会这样做.

Untested, but this is how I would do it.

KitAssemblyEntry kitGraph = CreateInstance<KitAssemblyEntry>();

INKitRegister kit = new INKitRegister();
// Sometimes need to set initial values here
kit = kitGraph.Document.Insert(kit);

kitGraph.Document.Cache.SetValueExt<INKitRegister.inventoryID>(kit, mixQLine.InventoryID);

//May need to do an interim update on the cache after setting certain fields
kit = kitGraph.Document.Update(kit);

kitGraph.Document.Cache.SetValueExt<INKitRegister.locationID>(kit, scales.LocationID);
kitGraph.Document.Cache.SetValueExt<INKitRegister.uOM>(kit, mixQLine.Uom);
kitGraph.Document.Cache.SetValueExt<INKitRegister.qty>(kit, mixQLine.Qty);

////////////////////////////////
//Alternate way to to set values
kit.InventoryID = mixQLine.InventoryID;

//May need to do an interim update on the cache after setting certain fields
kit = kitGraph.Document.Update(kit);

kit.LocationID = scales.LocationID;
kit.Qty = mixQLine.Qty;
kit.UOM = mixQLine.Uom;
////////////////////////////////

kit = kitGraph.Document.Update(kit);
kitGraph.Actions.PressSave();

这篇关于单个字段值不会在缓存更新时更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆