I'm getting a weird error when printing an SO Invoice through the BOI. It showed up when we upgraded to Sage 100 2013, Service Update 5. It worked correctly under Service Update 3, so I'm guessing the requirements for printing have changed. The error reads:
The S/O0000000038SO_INVOICEPRINTING_UI STANDARD 00001 is invalid.
Here is my code. You'll see in the comments where the error happens. Any help would be greatly appreciated. Thanks.
Jon
' Global Variables:
Private oScript As Object
Private oSS As Object
Private moduleDate As DateTime
Private Sub printInvoice(ByVal inv As Invoice)
moduleDate = DateTime.Today
Dim result As Int32 = 1
loginToMAS(""S/O"")
Dim soPrint As Object
result = oSS.nSetProgram(oSS.nLookupTask(""SO_InvoicePrinting_ui""))
If result = 0 Then Throw New MASException(oSS.sLastErrorMsg)
soPrint = oScript.NewObject(""SO_InvoicePrinting_rpt"", oSS)
oSS.nTerminateUI()
Dim repSetting As String = ""STANDARD""
result = soPrint.nSelectReportSetting(repSetting)
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetKeyValue(""ReportSetting$"", repSetting)
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
' New Code, added 8-6-14 (For compatibility with 2013)
result = soPrint.nSetKeyValue(""ModuleCode$"", ""S/O"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
Dim sCompanyKey As String = oSS.sCompanyKey
result = soPrint.nSetKeyValue(""CompanyKey$"", sCompanyKey)
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetKeyValue(""ReportID$"", ""SO_InvoicePrinting_ui"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetKeyValue(""RowKey$"", ""1"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetKey()
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
' Set Selection criteria
result = soPrint.nSetValue(""SelectField$"", ""Invoice Number"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetValue(""SelectFieldValue$"", ""Invoice Number"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetValue(""Tag$"", ""TABLE=SO_INVOICEHEADER; COLUMN=INVOICENO$"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetValue(""Operand$"", ""="")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetValue(""Value1$"", inv.invoiceNo)
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetValue(""KeyReference$"", inv.invoiceNo)
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nWrite()
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg)
result = soPrint.nSetPartialRecord(""Plain"", oScript.Evaluate(""CPL(""""IOLIST TemplateDesc$"""")""))
' THIS IS WHERE THE ERROR HAPPENS
result = soPrint.nProcessReport(""PRINT"")
If result = 0 Then Throw New MASException(soPrint.sLastErrorMsg) ' The error message is: The S/O0000000038SO_INVOICEPRINTING_UI STANDARD 00001 is invalid.
soPrint.DropObject()
cleanup()
End Sub
' Here are the two helper methods I call from printInvoice:
Private Sub loginToMAS(ByVal moduleCode As String)
Dim result As Integer = 1
oScript = New ProvideX.Script()
Dim SOTAMAS90Key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(""Software\ODBC\ODBC.INI\SOTAMAS90"")
Dim InitPath As String
InitPath = SOTAMAS90Key.GetValue(""Directory"") & ""\Home""
'InitPath = My.Settings.PathToMAS & ""\Home""
'Login to MAS
oScript.Init(InitPath)
oSS = oScript.NewObject(""SY_SESSION"")
result = oSS.nSetUser(creds.masUserID, creds.masPassword)
If result = 0 Then Throw New MASException(oSS.sLastErrorMsg)
'Select Company and Module date
result = oSS.nSetCompany(creds.masCompany)
If result = 0 Then Throw New MASException(oSS.sLastErrorMsg)
result = oSS.nSetDate(moduleCode, moduleDate.ToString(""yyyyMMdd""))
If result = 0 Then Throw New MASException(oSS.sLastErrorMsg)
result = oSS.nSetModule(moduleCode)
If result = 0 Then Throw New MASException(oSS.sLastErrorMsg)
End Sub
Private Sub cleanup()
oSS.nCleanUp()
oSS.DropObject()
oSS = Nothing
oScript = Nothing
End Sub