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 

Parents
  • Did you copy the [Paperless] section from the MAS90\Launcher\sota.ini to the MAS90\Home\pvx.ini file?

  • in reply to David Speck

    I had not, but it doesn't make a difference. I did that in the WKS install folder. Was that correct?

  • in reply to BillyVanilli

    I can't recall if it is needed for the workstation folder but if on Advanced, best to do it under both the server and the workstation.

  • in reply to David Speck

    I set it on the server as well. No success. I believe my issue is due to not being able to retrieve the report options, and then not being able to set this line:

    $retVal = $oARInvPrint.nReplaceDefault([ref]$sReportOptions, "DB_PAPERLESSOFFICEOUTPUT$", "2")

  • in reply to BillyVanilli

    Why are you not able to retrieve the report options?  In your snippet line 4 should work but line 6 isn't needed and doesn't have the prefix for the method indicating the returned data type.

    Before you attempt the nReplaceDefault on the options string, try displaying it in a message box so you can see what the current options are.  2016 may have used a different option name for some of them.

    Each time you use a method for the oPaperless, try checking the sLastErrorMsg property to see if anything is failing.  You can optionally set the sLastErrorMsg property to an empty string before each method call to make sure what you get after is related to the method you just called.

    Try checking the sLastErrorMsg property of the oARInvPrint object after the nProcessReport method.

Reply
  • in reply to BillyVanilli

    Why are you not able to retrieve the report options?  In your snippet line 4 should work but line 6 isn't needed and doesn't have the prefix for the method indicating the returned data type.

    Before you attempt the nReplaceDefault on the options string, try displaying it in a message box so you can see what the current options are.  2016 may have used a different option name for some of them.

    Each time you use a method for the oPaperless, try checking the sLastErrorMsg property to see if anything is failing.  You can optionally set the sLastErrorMsg property to an empty string before each method call to make sure what you get after is related to the method you just called.

    Try checking the sLastErrorMsg property of the oARInvPrint object after the nProcessReport method.

Children
No Data