您好我正在创建一个插入采购订单的流程,但我遇到了一个我无法解决的错误。当我保留我的采购订单时,我收到错误,RevisionID可能不是空的。我很困惑,并且RevisionID没有出现在任何DAC的POOrder或POLine上。
这是错误
Message: Error #4: 'RevisionID' may not be empty.
Date/Time: 18/06/2015 12:22
Platform:
Browser:
Source: PX.Data
Target Site: Boolean MoveNext()
Stack Trace: at PX.Data.PXDefaultAttribute.RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
at PX.Data.PXCache.OnRowPersisting(Object item, PXDBOperation operation)
at PX.Data.PXCache`1.PersistInserted(Object row)
at PX.Objects.CS.SharedRecordAttribute.RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
at PX.Data.PXCache.OnRowPersisting(Object item, PXDBOperation operation)
at PX.Data.PXCache`1.PersistInserted(Object row)
at PX.Data.PXCache`1.Persist(PXDBOperation operation)
at PX.Data.PXGraph.Persist(Type cacheType, PXDBOperation operation)
at PX.Data.PXGraph.Persist()
at PX.Objects.PO.POOrderEntry.Persist()
at PX.Data.PXSave`1.<Handler>d__4.MoveNext()
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Data.PXAction`1.<Press>d__c.MoveNext()
at PX.Data.PXAction`1.Press()
at Exosoft.MP.MikePero.Graphs.GeneratePurchaseOrdersProcess.GeneratePurchaseOrders (List`1 sOrderLines) in c:\Projects\Exosoft\Mike Pero Rex Integration\Dev\Main\Source\MP\MikePero\Graphs\Processes\GeneratePurchaseOrdersProcess.cs:line 102
这里是我创建采购订单的代码(未完成)
private static void GeneratePurchaseOrders(List<PX.Objects.SO.SOLineCustom> sOrderLines)
{
try
{
DateTime firstOfMonth = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1);
DateTime lastOfMonth = firstOfMonth.AddMonths(1).AddSeconds(-1);
foreach (PX.Objects.SO.SOLineCustom soLine in sOrderLines) {
POOrderEntry graph = PXGraph.CreateInstance<POOrderEntry>();
graph.Clear(PXClearOption.ClearAll);
PX.Objects.IN.InventoryItem item = AdvancedMethods.GetInventoryItemByInventoryID(soLine.InventoryID);
PX.Objects.AP.VendorR vendor = AdvancedMethods.GetVendorByID(item.PreferredVendorID);
if (vendor == null) return;
PX.Objects.CR.Location vLocation = AdvancedMethods.GetLocationByLocationID(vendor.DefLocationID);
if (vLocation == null) return;
//Get Existing Current Months Purchase Order
PX.Objects.PO.POOrder pOrder = PXSelect<PX.Objects.PO.POOrder,
Where<PX.Objects.PO.POOrder.vendorID, Equal<Required<PX.Objects.PO.POOrder.vendorID>>,
And<Where<PX.Objects.PO.POOrder.orderDate, Greater<Required<PX.Objects.PO.POOrder.orderDate>>,
And<PX.Objects.PO.POOrder.orderDate, LessEqual<Required<PX.Objects.PO.POOrder.orderDate>>>>>>>.Select(new PXGraph(), item.PreferredVendorID, firstOfMonth, lastOfMonth);
if (pOrder == null)
{
//Add new purchase order
pOrder = new PX.Objects.PO.POOrder();
pOrder.OrderType = PX.Objects.PO.POOrderType.RegularOrder;
pOrder = PXCache<PX.Objects.PO.POOrder>.CreateCopy(graph.Document.Insert(pOrder));
pOrder.VendorID = vendor.ID;
pOrder.VendorLocationID = vendor.DefLocationID;
pOrder.SiteID = soLine.SiteID;
pOrder.OrderDesc = "Generated Purchase Order";
pOrder.OrderDate = lastOfMonth;
pOrder.TermsID = vendor.TermsID;
}
graph.Document.Current = graph.Document.Search<POOrder.orderNbr>(pOrder.OrderNbr, pOrder.OrderType);
graph.vendor.Current = vendor;
graph.location.Current = vLocation;
//Add Line to Purchase Order
PX.Objects.PO.POLine pLine = new PX.Objects.PO.POLine();
pLine.LineType = POLineType.Service;
pLine.OrderType = pOrder.OrderType;
pLine.RequestedDate = soLine.ShipDate;
pLine.VendorID = pOrder.VendorID;
pLine.VendorLocationID = pOrder.VendorLocationID;
pLine.InventoryID = soLine.InventoryID;
pLine.SubItemID = pLine.SubItemID;
pLine.SiteID = soLine.SiteID;
pLine.UOM = soLine.UOM;
pLine.OrderQty = soLine.Qty;
pLine.TranDesc = soLine.TranDesc;
pLine.ProjectID = soLine.ProjectID;
pLine.TaskID = soLine.TaskID;
pLine.UnitCost = soLine.UnitCost;
pLine.CuryUnitCost = soLine.CuryUnitCost;
pLine = graph.Transactions.Insert(pLine);
graph.Save.Press();
}//foreach
}
catch (Exception ex)
{
ErrorHandling.LogError(ex);
throw new PXException(String.Format("An error occurred generating purchase orders: {0}", ex.Message));
}
}
}//GeneratePurchaseOrdersProcess
答案 0 :(得分:2)
好的,我在更改属性后忘记更新采购订单
pOrder = graph.Document.Update(pOrder);