I am trying access SO_SalesOrder_bus in order to set the print flags, but every time I try to create a new object for this object, it fails with this exception:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in CSH.dll
Additional information: Exception occurred. (Exception from HRESULT: 0x80020009 (DISP_E_EXCEPTION))
Client Version: Sage MAS 100 ERP 2013 v5.00.9.0
Here is my code:
retVal = oSS.nSetDate("S/O", AccountingDate)
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Accounting Date", oSS.sLastErrormsg))
End If
retVal = oSS.nSetModule("S/O")
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Set Module", oSS.sLastErrormsg))
End If
retVal = oSS.nSetProgram(oSS.nLookupTask("SO_SalesOrder_ui"))
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Get Task", oSS.sLastErrormsg))
End If
Dim SalesOrder_bus As Object = oScript.NewObject("SO_SalesOrder_bus", oSS)
retVal = SalesOrder_bus.nSetKey(OrderNo)
If retVal = 0 Then
logger.Log(String.Format("{0}: {1}", "Get Order", SalesOrder_bus.sLastErrormsg))
End If
Any ideas as to why it might be failing?
Some additional notes:
- This is the ONLY object failing - I am able to successfully create many other new objects on the same system, and even in the same subroutine that this code is in.
- This is in a subroutine that is designed to print sales orders. I tried setting these two flags via e-Business Web Services during order creation, but it doesn't seem to be having any effect. As a follow up question, would it be possible to load the sales order, set the flags, and then update via Web Services? If so, I will simply remove the BOI calls here.