我有一个操作按钮,该按钮正在读取物料行并根据该信息创建新的库存物料。这是代码:
public PXAction<CFBSCatalogHeader> ConvertToItem;
[PXButton()]
[PXUIField(DisplayName = "Convert to Item")]
protected void convertToItem()
{
CFBSCatalogDetail row = Details.Current;
if (row == null)
return;
InventoryItemMaint graph = PXGraph.CreateInstance<InventoryItemMaint>();
graph.Item.Current = graph.Item.Insert();
graph.Item.Current.InventoryCD = row.VendorPartID;
graph.Item.Current.Descr = row.Descr;
graph.Item.Current.ItemClassID = 526;
graph.Item.Current.ItemType = "M";
graph.Item.Current.ValMethod = "F";
graph.Item.Current.TaxCategoryID = "TAXDEFAULT";
graph.Item.Current.PostClassID = "INVDEFAULT";
graph.Item.Current.LotSerClassID = "LOTSNDEFAU";
graph.Item.Current.BaseUnit = "EA";
graph.Item.Current.SalesUnit = "EA";
graph.Item.Current.PurchaseUnit = "EA";
graph.Item.Update(graph.Item.Current);
graph.Actions.PressSave();
}
我收到此错误:
尽管有错误,该项目仍保存。我假设该记录试图保存一次以上,但是我不确定为什么。
编辑:
以下是错误的踪迹:
11/7/2018 8:21:48 AM错误: 错误:另一个进程已添加“ InventoryItem”记录。您的更改将>>丢失。
在PX.Data.PXCache`1.PersistInserted(对象行) 在PX.Data.PXCache`1.Persist(PXDBOperation操作) 在PX.Data.PXGraph.Persist(类型cacheType,PXDBOperation操作) 在PX.Data.PXGraph.Persist() 在F:\ Bld \ AC-FULL2018R112-JOB1 \ sources \ WebSites \ Pure \ PX.Objects \ IN \ NonStockItemMaint.cs:PX.Objects.IN.InventoryItemMaint.Persist() 在JAMS.AEF.InventoryItemMaintAMExtension.Persist(Action del) 在d:\ Program Files \ Acumatica ERP \ TexasScenic \ App_RuntimeCode \ VendorCatalog.cs:line 70中的CFBSModificationsTSC.VendorCatalog.convertToItem()中 在PX.Data.PXAction`1。<> c__DisplayClass3_0。<。ctor> b__0(PXAdapter适配器) 在PX.Data.PXAction`1.a(PXAdapter A_0) 在PX.Data.PXAction`1.d__31.MoveNext() 在PX.Data.PXAction`1.d__31.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(字符串viewName,DataSourceSelectArguments参数,PXDSSelectArguments pxarguments)
答案 0 :(得分:1)
您需要在插页上设置CD值...
graph.Item.Current = graph.Item.Insert(new InventoryItem { InventoryCD = row.VendorPartID });
然后像在样本中一样设置更新中的其余字段。