BOI - Printing of Purchase Orders - Unattended

SOLVED

Experts,

I have a script that prints Purchase Orders to PDF through BOI. The script works fine when I manually run it. If I run it unattended through Windows Task Scheduler, it doesn't print the PDFs. My logfiles show that all the return values are okay until

$retVal = $oPOPrint.nProcessReport("EXPORT"). I am not getting an error message from $oPOPrint, but the retVal is 0

Is Sage BOI capable of printing PDFs with no user logged in? If yes, what needs to be done to make it work?

Thanks for your help!

Bastian

  • 0
    SUGGESTED

    Is your path in Paperless set up as a mapped drive instead of UNC?  (Mapped drives are not available to Task Scheduler).

  • 0 in reply to Kevin M

    Thanks for the feedback Kevin. I checked and Paperless is set to print to a UNC path. Also my output was a UNC. I changed the output to a local folder on the server and will now test if that works.

    I actually do get an error message back on $retVal = $oPOPrint.nProcessReport("EXPORT").
    The message is "Select a template to use."

    It runs fine when I am logged in and run the script manually. The user that I use has printed the template in Sage before.

    Edit:

    I get the "Select a Template to use" error when I am logged in and run the script from the Windows Task Scheduler manually.

    Log example if run through Task Scheduler

    nSelectReportSetting = 1
    nSetOptions = 1
    nInitReportEngine = 1
    nSetExportOptions = 1
    nProcessReport = 0 | Select a template to use.
    nClear = 1

    Log example if run manually

    nSelectReportSetting = 1
    nSetOptions = 1
    nInitReportEngine = 1
    nSetExportOptions = 1
    nProcessReport = 1
    nClear = 1

  • 0 in reply to BillyVanilli
    SUGGESTED

    Without seeing more of your script, it is hard to pinpoint the problem, you may be missing a method or two.

    Also, at one point, it was a requirement to make sure the user used to authenticate in the script was used at least once to print/preview the form from within the sage 100 desktop.

    Another thing to consider is that if dealing with paperless, make sure the paperless section from MAS90\Launcher\SOTA.ini has been copied to the MAS90\Home\PVX.ini file.

    If on version 2018+, make sure the pvxwin32.exe.config file from MAS90\Home has been copied to C:\Program Files (x86)\Common Files\Sage\Common Components and renamed to pvxcom.exe.config.

  • 0 in reply to David Speck

    David,

    Thanks for looking at this. The user that is used for the login has printed the form code before. Also, the script works fine when I run it manually (not through Task Scheduler unattended).

    Here is a bigger code snippet:

     $sPDFPathFull = "$sPDFPath\$sPONo.pdf"
    Write-Host "File: $sPDFPathFull"
                
    $retVal =  $oPOPrint.nSelectReportSetting("$sForm")
    $sLogString += "`r`nnSelectReportSetting = $retVal"
    
    $oPOPrint.sQuickPrint = $sPONo
    $retVal =  $oPOPrint.nSetOptions("") # (options)
    $sLogString += "`r`nnSetOptions = $retVal"
                
    $oPOPrint.nReportType = 6
    
    $retVal =  $oPOPrint.nInitReportEngine()
    $sLogString += "`r`nnInitReportEngine = $retVal"
                
    $retVal =  $oPOPrint.nSetExportOptions(5, "$sPDFPathFull")
    $sLogString += "`r`nnSetExportOptions = $retVal"
    
    $retVal =  $oPOPrint.nProcessReport("EXPORT")
    $sErrorMsg = $oPOPrint.sLastErrorMsg()
    $sLogString += "`r`nnProcessReport = $retVal | $sErrorMsg"
                
    $retVal =  $oPOPrint.nClear()
    $sLogString += "`r`nnClear = $retVal"

    I might try using SumatraPDF and print via my script (not export as a PDF). I know that Sumatra can print silent.

  • 0 in reply to BillyVanilli

    Do you have the task running under a user that has the appropriate NTFS permissions required to run the sage 100 workstation and access the export path?

    If using the system account or network service account, it won't be able to access UNC or network paths.

  • 0 in reply to David Speck

    I suspect as well that has something to do with user rights. We are using a Domain Admin account, and within the same script I am writing a log file to the same location as the PDFs.

    Can you confirm that Sage should be able to Export PDFs with no user logged in on the computer?

  • 0 in reply to BillyVanilli

    it should be able to but you have to eliminate NTFS permissions and printer related issues.

    Make sure you log into the server where the task is scheduled with the user the task is set up to authenticate with and make sure the user has a valid default printer assigned, if not, assign it one.

  • +1 in reply to David Speck
    verified answer

    Also, have you tried manually running the task? does it report anything if you do?

    have you actually launched the sage 100 desktop and processed the report from beginning to end using the domain account used to authenticate for the scheduled task to rule out any first time prompts that might be triggered?

  • 0 in reply to David Speck

    Running the task manually through Task Scheduler produces the same error (on nProcessReport).

    I am using the same Administrator account for the task that I use to manually log onto the server. It's a good tip to check for that, but since the user is the same, there shouldn't be any new prompts I will try that again tomorrow. I also will try tomorrow to actually print instead of exporting.

  • +1 in reply to David Speck
    verified answer

    I finally figured it out. I am running the script on the Sage server. I used RDP to connect to the server and do the manual print. But that doesn't work because Sage recognizes that session as coming from the remote computer. I found that out by looking at the Master Console. It showed me logged in from the remote computer, and not the server. 

    By logging on to the server directly and printing manually once I was able to resolve the automation issue. 

    Thanks again for your help!