I have a PO that I am receiving against. I want to receive part of the line that exists as well as add a new line.
The existing line is received as expected. However, when I try to add the new line, it creates a line with the item code and unit cost that I specify, but the ordered quantity does not take.
I've tried changing the order that I create/receive the lines. The only hint I've found online is in PO Receipt of Goods Received Quantity not writing, but unlike the user there, I call nCopyPurchaseOrderLines once before I add the new line. I've duplicated my work within Sage and don't see any popups I need to handle or extra fields I need to set.
Does anyone have any ideas? Examples or documentation on the subject I can read?
PO: https://imgbox.com/o5NOv5xb
Resultant receipt: https://imgbox.com/4XwuX4Kb
SageResponse response; int r; object[] receiptNo = new object[] { string.Empty }; string retValue = 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); using (DispatchObject oBusObj = new DispatchObject(oScript.InvokeMethod("NewObject", "PO_Receipt_BUS", oSession.GetObject()))) { r = (int)oBusObj.InvokeMethod("nSelectBatch", string.Empty); r = (int)oBusObj.InvokeMethod("nSetKeyValue", "ReceiptType$", "G"); r = (int)oBusObj.InvokeMethodByRef("nGetNextReceiptNo", receiptNo); r = (int)oBusObj.InvokeMethod("nSetKeyValue", "ReceiptNo$", receiptNo[0].ToString() ?? string.Empty); r = (int)oBusObj.InvokeMethod("nSetKey"); r = (int)oBusObj.InvokeMethod("nSetValue", "ReceiptDate$", "20230808"); r = (int)oBusObj.InvokeMethod("nSetValue", "PurchaseOrderNo$", "137C"); r = (int)oBusObj.InvokeMethod("nCopyPurchaseOrderLines", 0); using (DispatchObject oLines = new DispatchObject(oBusObj.GetProperty("oLines"))) { #region Existing item 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 == "79") { r = (int)oLines.InvokeMethod("nSetValue", "QuantityReceived", 390.96); r = (int)oLines.InvokeMethod("nWrite"); }//if r = (int)oLines.InvokeMethod("nMoveNext"); }//while #endregion #region New item r = (int)oLines.InvokeMethod("nAddLine"); r = (int)oLines.InvokeMethod("nSetValue", "ItemCode$", "DOCK"); r = (int)oLines.InvokeMethod("nSetValue", "OriginalQtyOrdered", 390.96); r = (int)oLines.InvokeMethod("nSetValue", "UnitCost", -19.95); r = (int)oLines.InvokeMethod("nWrite"); #endregion }//using r = (int)oBusObj.InvokeMethod("nWrite"); }//using } else retValue = $"Invalid UI (PO_ReceiptOfGoods_UI)"; } else retValue = "Invalid Company"; } else retValue = "Invalid User Logon or Password"; }//using }//using