Quantcast
Viewing all articles
Browse latest Browse all 37027

Forum Post: C# PO Write Fails BOI

First, thanks in advance for taking a look at this. I'm looking at doing PO creation from C# and have been able to connect, get the next PO number etc., but everytime I try to finalize the PO, such as call the "nWrite" command, it always fails. Any insight into what could be happening? Below is my code. using (DispatchObject poObject = new DispatchObject(pvx.InvokeMethod("NewObject", "PO_PurchaseOrder_bus", oSS.GetObject()))) { try { string poNumber = ""; //int test1 = (int)poObject.InvokeMethod("nGetNextPurchaseOrderNo"); object[] poPass = new object[] {poNumber}; successCheck((int)poObject.InvokeMethodByRef("nGetNextPurchaseOrderNo", poPass), "GetNextPurchaseOrder"); //this was just to see what the PO number was coming back. poNumber = poPass[0].ToString(); //we continue successCheck((int) poObject.InvokeMethodByRef("nSetKey", poPass), "SetKey"); object[] divisionNoObject = new object[] {"APDivisionNo$", "00"}; successCheck((int) poObject.InvokeMethodByRef("nSetValue", divisionNoObject), "SetDivisionNo"); object[] vendorObject = new object[] { "VendorNo$", "0006630" }; successCheck((int)poObject.InvokeMethodByRef("nSetValue", vendorObject), "SetVendorNo"); object[] taxObject = new object[] { "TaxSchedule$", "NONTAX" }; successCheck((int)poObject.InvokeMethodByRef("nSetValue", taxObject), "SetTaxSchedule"); DispatchObject poLines = new DispatchObject(poObject.GetProperty("oLines")); successCheck((int)poLines.InvokeMethod("nAddLine"), "AddLine"); object[] firstLine = new object[] { "ItemCode$", "/1." }; successCheck((int)poLines.InvokeMethodByRef("nSetValue", firstLine), "PoLineItemCode"); firstLine[0] = "QuantityOrdered"; firstLine[1] = "1"; successCheck((int)poLines.InvokeMethodByRef("nSetValue", firstLine), "PoLineQuantityOrdered"); successCheck((int)poLines.InvokeMethod("nWrite"), "PoLinesWrite"); successCheck((int) poObject.InvokeMethod("nWrite"), "Write"); MessageBox.Show("SUCCESS! " + poNumber.ToString()); } catch (Exception ex) { MessageBox.Show(ex.Message); } } And below is my successCheck method to see what fails. public void successCheck(int checkValue, string call) { if (checkValue == 0) { MessageBox.Show("Error! " + call); } }

Viewing all articles
Browse latest Browse all 37027

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>