Paperless Office Email from AR Invoice History Printing Report through BOI

Experts,

I have an issue with automating invoice emails through Paperless from the AR Invoice History Printing report. The code below works fine in my test environment but fails (without an error) in the target environment.

My test environment is v2020 Standard and the target environment is v2016 Premium.

The following code is used to get/modify, and set the report options (thanks )

	            $sReportOptions = ''
                $retVal = $oARInvPrint.nGetOptions([ref]$sReportOptions)

                # Replace the report option specified in the second argument with the value specified in the third argument.
	            $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions,"CB_UNPAIDINVSONLY$","N")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "DB_PRINTCOMMENT$", "F")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "DB_PAPERLESSOFFICEOUTPUT$", "2")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_INVMSG1$", "")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_HISTMSG1$", "")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_INVMSG2$", "")
                $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_HISTMSG2$", "")
	
                # Set the modified report options.
	            $retVal = $oARInvPrint.nSetOptions([ref]$sReportOptions)

In my test environment the nGetOptions properly returns the proper options string, but in the target environment I am not getting anything back. The retVal is 0, but there is no error message on the object. The nSetOptions works. I tried it with the hardcoded connection string that I took out of my test environment. I could use that, but I don't want to hardcode the value for the ;ELECTRONICDELIVERYOPTIONS$="" property in my code, because it looks like this is company-specific based on the email settings.

The script proceeds to $retVal = $oARInvPrint.nProcessReport("PRINT") and returns 0. Again, no error message available.

Here is the whole snippet:

# Send Invoices via Paperless
# Get the current report options.
$sReportOptions = ''
$retVal = $oARInvPrint.nGetOptions([ref]$sReportOptions)

sReportOptions = "" : oReport_Rpt.GetOptions sReportOptions

# Replace the report option specified in the second argument with the value specified in the third argument.
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions,"CB_UNPAIDINVSONLY$","N")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "DB_PRINTCOMMENT$", "F")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "DB_PAPERLESSOFFICEOUTPUT$", "2")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_INVMSG1$", "")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_HISTMSG1$", "")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_INVMSG2$", "")
$retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "ML_HISTMSG2$", "")

# Set the modified report options.
$retVal = $oARInvPrint.nSetOptions([ref]$sReportOptions)

# Set Selection Criteria 1
$retVal = $oARInvPrint.nSetKeyValue("ModuleCode$", $oSS.sModuleCode())
$retVal = $oARInvPrint.nSetKeyValue("CompanyKey$", $oSS.sCompanyKey())
$retVal = $oARInvPrint.nSetKeyValue("ReportID$", $oARInvPrint.sReportID())
$retVal = $oARInvPrint.nSetKeyValue("ReportSetting$", $sFormCode)
$retVal = $oARInvPrint.nSetKeyValue("RowKey$", "00001")
$retVal = $oARInvPrint.nSetKey()
$retVal = $oARInvPrint.nSetValue("SelectField$", "Invoice Date")
$retVal = $oARInvPrint.nSetValue("SelectFieldValue$", "Invoice Date")
$retVal = $oARInvPrint.nSetValue("Tag$", "TABLE=AR_INVOICEHISTORYHEADER; COLUMN=INVOICEDATE$;")
$retVal = $oARInvPrint.nSetValue("Operand$", "=")
$retVal = $oARInvPrint.nSetValue("Value1$", [ref]$sInvoiceDate)
$retVal = $oARInvPrint.nSetValue("KeyReference$", "")
$retVal = $oARInvPrint.nWrite()

# Set Selection Criteria 2
$retVal = $oARInvPrint.nSetKeyValue("ModuleCode$", $oSS.sModuleCode())
$retVal = $oARInvPrint.nSetKeyValue("CompanyKey$", $oSS.sCompanyKey())
$retVal = $oARInvPrint.nSetKeyValue("ReportID$", $oARInvPrint.sReportID())
$retVal = $oARInvPrint.nSetKeyValue("ReportSetting$", $sFormCode)
$retVal = $oARInvPrint.nSetKeyValue("RowKey$", "00002")
$retVal = $oARInvPrint.nSetKey()
$retVal = $oARInvPrint.nSetValue("SelectField$", "UDF_INVOICETYPE")
$retVal = $oARInvPrint.nSetValue("SelectFieldValue$", "UDF_INVOICETYPE")
$retVal = $oARInvPrint.nSetValue("Tag$", "TABLE=AR_INVOICEHISTORYHEADER; COLUMN=UDF_INVOICETYPE$;")
$retVal = $oARInvPrint.nSetValue("Operand$", "=")
$retVal = $oARInvPrint.nSetValue("Value1$", "IN")
$retVal = $oARInvPrint.nSetValue("KeyReference$", "")
$retVal = $oARInvPrint.nWrite()

$oARInvPrint.nEmailSelected = 1

$oPaperless = 0
$oPaperless = $oARInvPrint.ocoPLCommon()

$retVal = $oPaperless.sFormPrintUISelection = "2"

$oEmailEngine = 0
$oEmailEngine = $oARInvPrint.oEmailEngineObj()
$oEmailEngine.nEESilent = 1 #show email results

$retval = $oPaperless.nElectronicDelivery("",0,[ref]$oEmailEngine,0, "","",1) #last argument 0 hide / 1 show email interface

$retVal = $oARInvPrint.nProcessReport("PRINT")

I have another piece of code in that script that just prints to deferred, and that one works in my test and in the target environment.

Does anyone have an idea why that would fail in v2016 and what I need to do to be able to email these invoices out?

Thanks!

Bastian