我正在尝试将新记录插入数据库中的自定义表。这是通过SO图上的图形扩展来执行的。代码如下:
public PXAction<PX.Objects.SO.SOOrder> addToDatabase;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "Send to Manufacturing")]
protected void AddToDatabase()
{
try
{
Flow2 graphWO = PXGraph.CreateInstance<Flow2>();
EMPWorkOrder wo = null;
foreach (PXResult<SOLine, InventoryItem> line in PXSelectJoin<SOLine, LeftJoinSingleTable<InventoryItem, On<InventoryItem.inventoryID, Equal<SOLine.inventoryID>>>,
Where<SOLine.orderNbr, Equal<Current<SOOrder.orderNbr>>>>.Select(Base, Base.Document.Current.OrderNbr))
{
PXCache sender = Base.Transactions.Cache;
SOLine soLine = (SOLine)line;
InventoryItem item = (InventoryItem)line;
SOLineExt lineExt = sender.GetExtension<SOLineExt>(soLine);
if (lineExt.UsrisSentToManufacturing != true)
{
wo = new EMPWorkOrder();
wo.Soid = Base.Document.Current.OrderNbr;
wo.ItemCD = item.InventoryCD;
wo.LineNbr = soLine.LineNbr;
wo.QtyReceived = 0;
wo.DateReceived = null;
wo.QtyComplete = 0;
wo.QtySentToInventory = 0;
wo.RouteId = "0";
wo.KitId = -1;
wo.IsStarted = false;
wo.NoteID = Guid.NewGuid();
graphWO.Document.Insert(wo);
graphWO.Actions.PressSave();
graphWO.Clear();
}
}
throw new PXException("Successfully moved to Manufacturing");
}
}
执行代码时,我收到的错误如下:
错误#14:插入&#39; EMPWorkOrder&#39;记录引发一个或多个错误。请查看。
当我进入追踪时,这是它给我的信息:
12/16/2016 1:44:23 PM错误: 错误#14:插入&#39; EMPWorkOrder&#39;记录引发一个或多个错误。请查阅。
at PX.Objects.SO.SOOrderEntry_Extension.AddToDatabase() 在PX.Data.PXAction`1。&lt;&gt; c__DisplayClass3_0。&lt; .ctor&gt; b__0(PXAdapter适配器)
在PX.Data.PXAction`1.a(PXAdapter A_0)
at PX.Data.PXAction`1.d__31.MoveNext()
at PX.Data.PXAction`1.d__31.MoveNext()
在PX.Web.UI.PXBaseDataSource.tryExecutePendingCommand(String viewName,&gt; String [] sortcolumns,Boolean [] descendings,Object [] search,Object []&gt;参数,PXFilterRow []过滤器,DataSourceSelectArguments参数,&gt; ; Boolean&amp; closeWindowRequired,Int32&amp; adapterStartRow,Int32&amp; adapterTotalRows)
at PX.Web.UI.PXBaseDataSource.ExecuteSelect(String viewName,DataSourceSelectArguments arguments,PXDSSelectArguments pxarguments)
我的记录是否有任何理由不插入我制作的自定义表格中?如果您需要任何其他信息来解决此问题,请随时提出。
答案 0 :(得分:1)
Eric,您很可能会因为使用PXDefaultAttribute修饰的一些空字段或字段(未分配值或空值)而收到此错误。在调试器下运行代码时,您应该通过最初抛出的异常的InnerException属性访问更详细的异常。
另外,我还建议您在操作委托开始时在BQL查询的Where子句中添加SOLine.orderType字段,因为为SOOrder DAC定义了2个关键字段:OrderType和OrderNbr < / p>