Sales Order Invoices don't get emailed from BOI script when run with Windows Task Scheduler.

I created a BOI script that selects a batch of invoices, PDF's them, emails them, updates and PDF's the sales register and updates and PDF's the DTR in 2022 Advanced.  The script works fine when run manually from the desktop.  When running it from Windows Task Scheduler, the invoices don't get PDF'd and they don't get emailed but the sales register and DTR both get PDF'd.  The Task Scheduler task is set up under the same Windows login as I am using when triggering the script manually and it's set to run elevated.  The BOI script logs into Sage with the same user/pw as I use when running manually.  The "old" fix for this was to copy the [PAPERLESS] section from sota.ini to pvx.ini.  However, there is no [PAPERLESS] section in sota.ini anymore.  Any suggestions would be appreciated.

  • 0

    Have you watched it being run from the Windows Task Scheduler to see if any error messages occurred during the process?  Have you thought of putting a [PAPERLESS} section back into the sota.ini   What is happening just before the invoices are to be emailed out?

  • 0

    Are you testing with the same Windows login used in the Task Scheduler as you are manually from that desktop?

  • 0 in reply to BigLouie

    I did think of adding the [PAPERLESS] section manually but I wasn't sure if what i have from 2016 would work in 2022.  Here's what i have:

    [Paperless]
    Name=Sage 100 ERP
    Driver==UAlMFOcHU'UUU'UUlc4G]GfAfMuGlRGFuM88U4GOFu]]H'fH4]8GAHFGuFHRMURUlcH'HffOFARUcGll4ucfUAf'4GucMGMR8G8Hl8OuGMuR
    Printer=Sage 100 PDF Converter
    Version=5.0

    I believe that the Version would need to be changed and I'm not sure that the driver info would be appropriate since the Amuni driver changed.

  • 0 in reply to Ray P

    At this point, I would write to a log after each BOI method to include the return code and any value added to the relevant object's ".LastErrorMsg" having cleared it first.

  • 0

    Figured it might help if I included the section of the script that I'm having the issue with.

    retVal = oSS.nSetProgram(oSS.nLookupTask("SO_InvoicePrinting_UI"))
    Set oSO_InvPrint = oPVX.NewObject("SO_InvoicePrinting_rpt", oSS)
    
    retVal = oSO_InvPrint.nSelectBatch(vBatchNo)
    retVal = oSO_InvPrint.nSelectReportSetting("TEST")  'Change "CUSTOM" to the correct form name
    
    oSO_InvPrint.nEmailSelected = 1
    Set oPaperless = oSO_InvPrint.ocoPLCommon
    oPaperless.sFormPrintUISelection = "2"  'Electronic Delivery Only (Includes PDF)
    oSO_InvPrint.oEmailEngineObj.nEESilent = 1
    retVal = oPaperless.nElectronicDelivery("",0,oSO_InvPrint.oEmailEngineObj,0, "","",1)
    
    If vPrintAlreadyPrinted = "Y" Then  'Emulates checking the "Print Invoices Already Printed" checkbox on the printing screen
    	oSO_InvPrint.nGetOptions sReportOptions
    	oSO_Invprint.nReplaceDefault sReportOptions, "CB_PRINTINVOICESPRINTED$", "Y"
    	oSO_Invprint.nSetOptions sReportOptions
    End If
    
    retVal = oSO_InvPrint.nDisableUseOfUI()	
    retVal = oSO_InvPrint.nProcessReport(vDestination)
    retVal = oSO_InvPrint.nEndOfPDFConverterJob()
    retVal = oSO_InvPrint.nUpdateLastForm()  'Make Sage remember the last form used to print the invoices
    oSO_InvPrint.DropObject		
    'msgbox("Invoices Printed")



  • 0 in reply to Ray P

    retVal = oSO_InvPrint.nSelectReportSetting("TEST")   This form code exists in Sage and had been printed to by the user in the script.

  • 0 in reply to Ray P

    You could save yourself a lot of time with isolating this by adding small bit of logging support to the script.

    Set fso = CreateObject("Scripting.FileSystemObject")
    If fso.FileExists(sEnhancementPath  & "\" & sFile & "." & "log") Then
    Set ts = fso.OpenTextFile(sEnhancementPath  & "\" & sFile & "." & "log", 8)
    Else
    Set ts = fso.CreateTextFile(sEnhancementPath  & "\" & sFile & "." & "log", True)
    End If
    ...
    oObject.sLastErrorMsg = ""
    ...
    ts.WriteLine vbCr & FormatDateTime(Date, vbShortDate) & " " & FormatDateTime(Time, vbLongTime) & vbTab & SCRIPT_ID & "<<method>> retVal =" & retVal & oObject.sLastErrorMsg"