As a follow-up/refinement to my previous question, I am wondering how to set the OriginalOrderQty on a line on a Receipt of Goods that I have entered by hand. In an effort to isolate my issue, I have created this PO (here) and this Receipt of Goods (here) from the GUI. I am able to set an ordered amount on the "DOCK" line from the GUI by double clicking in the Ordered column and entering a value.
I am trying to use the code below to set the OriginalOrderQty programmatically. The code gives no error messages, but nothing changes. Is this feature not available form the BOI? Do I need to validate or commit the row somehow for it to allow me to make changes? Does anyone have links to code examples or documentation that I can leverage?
string retValue = string.Empty; int r; object[] receiptNo = new object[] { string.Empty }; using (DispatchObject oScript = new DispatchObject("ProvideX.Script", _sys_ss.SageServer)) { oScript.InvokeMethod("Init", _sys_ss.SageInstall); using (DispatchObject oSession = new DispatchObject(oScript.InvokeMethod("NewObject", "SY_Session"))) { if ((int)oSession.InvokeMethod("nSetUser", _sys_ss.UserLogon, _sys_ss.Password) == 1) { if ((int)oSession.InvokeMethod("nSetCompany", _sys_ss.CompanyCode) == 1) { r = (int)oSession.InvokeMethod("nSetModule", "P/O"); r = (int)oSession.InvokeMethod("nSetDate", "P/O", DateTime.Now.ToString("yyyyMMdd")); int TaskID = (int)oSession.InvokeMethod("nLookupTask", "PO_ReceiptOfGoods_UI"); if (TaskID != 0) { oSession.InvokeMethod("nSetProgram", TaskID); DispatchObject oBusObj = new DispatchObject(oScript.InvokeMethod("NewObject", "PO_Receipt_BUS", oSession.GetObject())); r = (int)oBusObj.InvokeMethod("nSelectBatch", "00611"); r = (int)oBusObj.InvokeMethod("nSetKeyValue", "ReceiptType$", "G"); r = (int)oBusObj.InvokeMethod("nSetKeyValue", "ReceiptNo$", "003487"); r = (int)oBusObj.InvokeMethod("nSetKey"); using (DispatchObject oLines = new DispatchObject(oBusObj.GetProperty("oLines"))) { #region Existing items r = (int)oLines.InvokeMethod("nMoveFirst"); while ((int)oLines.InvokeMethod("nEOF") != 1) { object[] parameters = new object[] { "ItemCode$", "" }; r = (int)oLines.InvokeMethodByRef("nGetValue", parameters); string itemCode = (string)parameters[1]; if (itemCode == "DOCK") { r = (int)oLines.InvokeMethod("nSetValue", "OriginalOrderQty", 6); r = (int)oLines.InvokeMethod("nWrite"); }//if r = (int)oLines.InvokeMethod("nMoveNext"); }//while #endregion r = (int)oBusObj.InvokeMethod("nWrite"); }//using } else retValue = $"Invalid UI"; } else retValue = "Invalid Company"; } else retValue = "Invalid User Logon or Password"; }//using }//using