单个字段值不会在缓存更新时更新
Single field value won't update on cache update
我正在尝试插入 INKitRegister
项目。这是代码:
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 以分配默认位置,则该项目会为所有其他字段正确插入,但如果不正确,则会抛出此错误:
Error: Inserting 'IN Kit Split' record raised at least one error. Please review the errors.
我做错了什么?
'The errors':
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 和比例都是 non-null,引用的字段也是 non-null。但是,您应该通过 Document.Insert(kit); 模拟“插入”按钮以插入新的 INKitRegister。有时,您需要在记录中填写一些值(例如在 Sales Order 上输入 SOType),然后再插入,但在大多数情况下我不需要这样做。如果您的记录存在,通常您会通过以下方式搜索记录:
Document.Current = Document.Search<keyField>(keyValue);
在视图上使用 Insert 方法将确保创建记录时会在图表中触发所有正确的事件。我最好的猜测是这是潜在的问题,尽管在设置某些字段之前您可能需要对缓存进行临时更新。 (例如,如果位置与 inventoryID 相关联,您可能需要使用 inventoryID 更新缓存,以便 DAC 更新选择器并检索适用于该项目的位置。)
未经测试,但我会这样做。
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();
我在我的一个项目中使用了下面的代码,它按预期工作。此代码可能对您有所帮助。
KitAssemblyEntry kitGraph = PXGraph.CreateInstance<KitAssemblyEntry>();
INKitRegister objkitregister = PXCache<INKitRegister>.CreateCopy(kitGraph.Document.Insert(new INKitRegister()));
objkitregister.InventoryID = kitspecifications.KitInventoryID;
objkitregister.KitRevisionID = SOKitRevisionID;
objkitregister.Hold = false;
objkitregister.Qty = Requiredkitqty;
objkitregister = kitGraph.Document.Update(objkitregister);
kitGraph.Save.Press();
if (kitGraph.Actions.Contains("Release"))
{
kitGraph.Actions["Release"].Press();
}
我正在尝试插入 INKitRegister
项目。这是代码:
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 以分配默认位置,则该项目会为所有其他字段正确插入,但如果不正确,则会抛出此错误:
Error: Inserting 'IN Kit Split' record raised at least one error. Please review the errors.
我做错了什么?
'The errors':
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 和比例都是 non-null,引用的字段也是 non-null。但是,您应该通过 Document.Insert(kit); 模拟“插入”按钮以插入新的 INKitRegister。有时,您需要在记录中填写一些值(例如在 Sales Order 上输入 SOType),然后再插入,但在大多数情况下我不需要这样做。如果您的记录存在,通常您会通过以下方式搜索记录:
Document.Current = Document.Search<keyField>(keyValue);
在视图上使用 Insert 方法将确保创建记录时会在图表中触发所有正确的事件。我最好的猜测是这是潜在的问题,尽管在设置某些字段之前您可能需要对缓存进行临时更新。 (例如,如果位置与 inventoryID 相关联,您可能需要使用 inventoryID 更新缓存,以便 DAC 更新选择器并检索适用于该项目的位置。)
未经测试,但我会这样做。
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();
我在我的一个项目中使用了下面的代码,它按预期工作。此代码可能对您有所帮助。
KitAssemblyEntry kitGraph = PXGraph.CreateInstance<KitAssemblyEntry>();
INKitRegister objkitregister = PXCache<INKitRegister>.CreateCopy(kitGraph.Document.Insert(new INKitRegister()));
objkitregister.InventoryID = kitspecifications.KitInventoryID;
objkitregister.KitRevisionID = SOKitRevisionID;
objkitregister.Hold = false;
objkitregister.Qty = Requiredkitqty;
objkitregister = kitGraph.Document.Update(objkitregister);
kitGraph.Save.Press();
if (kitGraph.Actions.Contains("Release"))
{
kitGraph.Actions["Release"].Press();
}