Hi guys, So I have run into a bug in Sage 100 that affects printing using the BOI. The problems seem to affect versions 5.00.5.0 and later. Prior to that version, the problems don't seem to exist. The script below prints an SO Invoice. You'll need to edit it to point to your MAS Home directory, put in your credentials, and a enter valid SO Invoice number. To run the script, save it to your desktop (as a .vbs file), change the 5 variables at the top to valid values, save it, and double-click it. I would be most grateful if you could run it, then reply back with: 1. Did it work (you'll get a message box with either "DONE" or an error message). 2. Your Sage 100 Version (under Help -> Aboiut Sage 100 ERP) Thanks! Aaron Here is the script: ' BOI TEST SCRIPT ' FILL IN THE FOLLOWING 5 FIELDS WITH THE CORRECT VALUES FROM YOUR SETUP MasCompany = "ABC" ' put in desired Company MasUser = "usr" ' put in your own MAS User ID MasPassword = "password" ' put in your own password sPathHome = "C:\Sage\Sage 100 Standard ERP\MAS90\Home\" ' Put in your own path to MAS home folder invoiceNo = "0100058" ' put in your own S/O invoice number ' Create ProvideX Shell Set objShell = CreateObject("WScript.Shell") 'Create ProvideX COM Object Set oScript = CreateObject ("ProvideX.Script") 'Run Init method of COM object oScript.Init(sPathHome) 'Create Session Object Set oSS = oScript.NewObject("SY_Session") ' SetUser Method rtnUser = oSS.nSetUser(MasUser, MasPassword) If rtnUser = 0 Then sLastError = oSS.sLastErrorMsg sMsg = "Oops could not login to MAS." & vbCRLF & _ "Last Error: " & sLastErrorMsg & vbCRLF & _ "Program exiting .." MsgBox sMsg Wscript.Quit End If ' Set the company, module date and module for the Session rtnCompany = oSS.nSetCompany(MasCompany) rtnDate = oSS.nSetDate("S/O","20140818") rtnModule = oSS.nSetModule("S/O") If rtnModule = 0 Then sLastError = oSS.sLastErrorMsg sMsg = "Oops could not set Sales Order (S/O) as the module." & vbCRLF & _ "Last Error: " & sLastError & vbCRLF & _ "Program exiting .." MsgBox sMsg Wscript.Quit End If oSecurity = oSS.nSetProgram(oSS.nLookupTask("SO_InvoicePrinting_ui")) Set soPrint = oScript.NewObject("SO_InvoicePrinting_rpt", oSS) oSS.nTerminateUI() 'Dont do this if previewing repSetting = "STANDARD" result = soPrint.nSelectReportSetting(repSetting) result = soPrint.nSetKeyValue("ModuleCode$", "S/O") result = soPrint.nSetKeyValue("CompanyKey$", oSS.sCompanyKey) result = soPrint.nSetKeyValue("ReportID$", "SO_InvoicePrinting_ui") result = soPrint.nSetKeyValue("ReportSetting$", repSetting) result = soPrint.nSetKeyValue("RowKey$", "00001") result = soPrint.nSetKey() result = soPrint.nSetValue("SelectField$", "Invoice Number") result = soPrint.nSetValue("SelectFieldValue$", "Invoice Number") result = soPrint.nSetValue("Tag$", "TABLE=SO_INVOICEHEADER; COLUMN=INVOICENO$;") result = soPrint.nSetValue("Operand$", "=") result = soPrint.nSetValue("Value1$", invoiceNo) result = soPrint.nSetValue("KeyReference$", "") 'Set the important QuickPrint flag soPrint.sQuickPrint = invoiceNo 'Write to memory result = soPrint.nWrite() 'Set the TempalteDesc value - needed for 2013 and higher result = soPrint.nSetPartialRecord("Plain", oScript.Evaluate("CPL(""IOLIST TemplateDesc$"")")) result = soPrint.nProcessReport("PRINT") If result = 0 Then MsgBox "Last error on nProcessReport = " & soPrint.sLastErrorMsg End If 'Clean Up r = soPrint.DropObject() oSS.nCleanUp() oSS.DropObject() Set oSS = Nothing : Set oScript = Nothing : Set soPrint = Nothing Wscript.Echo "DONE" Wscript.Quit
↧