我已经编写了一些用于通过代码创建po的代码,但它错误地显示错误消息:“CS错误:无法生成序列的下一个数字。”
我该如何解决这个问题?我错过了什么?感谢帮忙!
protected void createPO() {
POOrder order = new POOrder();
POOrderEntry graph = PXGraph.CreateInstance < POOrderEntry > ();
order.OrderType = "Normal";
order.OrderDesc = "some text";
order.EmployeeID = 215;
order.Hold = false;
var branch = (Branch)PXSelect<Branch, Where<Branch.branchCD, Equal<Required<Branch.branchCD>>>>.Select(Base, "WEST");
graph.FieldDefaulting.AddHandler<POOrder.branchID>((s, e) =>
{
e.NewValue = branch.BranchID;
e.Cancel = true;
});
order.VendorID = 79;
order = graph.CurrentDocument.Insert(order);
graph.CurrentDocument.Update(order);
graph.Actions.PressSave();
throw new PXRedirectRequiredException(graph, null);
}
答案 0 :(得分:1)
首先尝试简单地看看它是否有效......
protected void createPO()
{
var graph = PXGraph.CreateInstance<POOrderEntry>();
var order = graph.Document.Insert(new POOrder());
order.OrderType = POOrderType.RegularOrder; // This is the default so not necessary
order.OrderDesc = "some text";
order.EmployeeID = 215;
order.Hold = false;
order.VendorID = 79;
graph.Document.Update(order);
graph.Actions.PressSave();
throw new PXRedirectRequiredException(graph, null);
}
使用“文档”视图代替基于Document当前记录的CurrentDocument视图。文档是主要视图,应使用主视图。
对于采购订单类型,与列表值相关的属性应该用于数据库的存储值(与您显示的列表值相比)。例如order.OrderType = POOrderType.RegularOrder
。这也是PO的默认值,因此除非您想在POOrderType
类中找到不同的常量,否则无需设置此值。