Working with External objects

Started by HendersonS, December 05, 2025, 12:43:47 PM

Previous topic - Next topic

HendersonS

Hi everyone. Lately, we've been working with third-party objects to interact with xmlsig, CR reports, etc., and we're having the same problem when passing a value to a method that requires another object as its constructor, or when passing a boolean value to the method. Does anyone know how we should handle these kinds of interactions? Thanks in advance.

Example with cr reports:
!
 DEF OBJECT CR_APP,"CrystalRuntime.Application"
 LET REPORT=CR_APP'OPENREPORT("C:\temp\customers.rpt") ! // This opens the report and creates the 'Report' object
 !
 LET EXP=REPORT'EXPORTOPTIONS
 LET EXP'DESTINATIONTYPE=1
 LET EXP'FORMATTYPE=31 ! pdf
 LET EXP'PDFEXPORTALLPAGES=-1
 LET EXP'DISKFILENAME$="C:\temp\customers.pdf")
 !CR Expects a boolean (true or false) !false no show dialog
 REPORT'EXPORT(0) ! this give an error 88 Invalid/unknown property name

example with xmlsig:
DEF OBJECT SIG,"Chilkat.XmlDSigGen.11" ! xmlsigner object
DEF OBJECT CERT,"Chilkat.Cert.11" ! cert object
LET CERT'LOADPFXFILE("C:\temp\cert.p12","pass")
LET C=CERT'LOADPFXFILE("C:\temp\cert.p12","pass") ! also we try this
LET SIG'SETX509CERT(CERT,1) ! this give an error 88 Invalid/unknown property name
LET SIG'SETX509CERT(C,1) !this give an error 88 Invalid/unknown property name ! also we try this

James Zukowski

Have you tried passing "true" or "false" instead of 1 or 0?
James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

HendersonS

hi james, yes, we have tried with: true,false,"true","false",$00$,-1,0, and in all cases we get the same error.

Devon Austen

Check the properties and methods available to pxplus by doing a

print EXP'*
or
print SIG'*

You can verify that Export() and SETX509CERT() are methods.

Other things to debug is check msg(-1) after you get the error for any more detailed error info. You could also checked

print EXP'PvxError$ for the same.
Principal Software Engineer for PVX Plus Technologies LTD.

Astecom - Koen

No idea about the report issue, using a 1 or 0 for True of False generally works.

The xmlsig issue can probably be fixed by prefixing cert with a *:
LET SIG'SETX509CERT(*CERT,1)

Passing a COM-object to another COM-object needs a * prefix.

HendersonS

Hi Koe, thanks for your help. Adding * to the constructor worked correctly.



Devon,about the other issue, i can confirm that this method exists. In fact, if we try it without arguments like report'export(), it works, but it displays a dialog box, and we don't want that, I have attached an image of what msg(-1) tells me, but it doesn't give me any indication of how to fix it or what might be causing the exception.

Devon Austen

You will have to look at the documentation for the COM object method you are trying to execute. Maybe the arg list is different then you expect?
Principal Software Engineer for PVX Plus Technologies LTD.

HendersonS

Devon, According to the documentation, I should send true or false. I even tested it with PowerShell and VB.NET, and it works by sending the parameter false, so the problem seems to be in how PXPlus sends the value to the method.

Mike King

The routine may require that you explicitly pass a boolean.  If so you can likely define a *VARIANT object, set its type to boolean and value then pass that.

Here is some information on *VARIANT

https://manual.pvxplus.com/PXPLUS/Automation%20in%20PxPlus/PxPlus%20COM%20Interface%20Extensions/Overview.htm#variant
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

HendersonS

Mike, thanks for your reply. Could you give me an example of how to pass a boolean value false because my attempts are receiving the same error?

We try:
DEF OBJECT V,"*VARIANT"
LET V'TYPE$="B"
LET V'VAL$="0"
! LET V'VAL$="FALSE" !ALSO TRY THIS
REPORT'EXPORT(*V)
!REPORT'EXPORT(V) ! also try this

Mike King

Have you tried setting 'VAL$ of the *VARIANT object then changing its type?

->def object v,"*variant"
->v'val$="false"
->?v'val$
false
->print v'type$
S
->v'type$="B"
->print v'val
 0
->v'val$="true"
->print v'type$
S
->v'type$="B"
->print v'val$
-1
As per the docs, setting the type will cause the *VARIANT to properly convert the value.
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

HendersonS

Mike, I tried doing it as you instructed, but I'm still getting the same error.

DEF OBJECT v,"*VARIANT"
v'val$="false"
v'type$="B"
PRINT v'val$
0
report'export(*v)
report'export(v) !also try this
Error #88: Invalid/unknown property name
Exception occurred (err/ret=2/0)


James Zukowski

Have you tried starting with numeric values to convert to Boolean? Would this work?

DEF OBJECT v,"*VARIANT"
v'val=1
v'type$="B"
PRINT v'val
-1
v'val=0
v'type$="B"
PRINT v'val
0

James Zukowski
Sr. Developer - J&E

BRAND>SAFWAY
Brand Industrial Services

Mike King

I suspect your call to the export method is incorrect.

I did a search on the web and on this page found an example that appears to show the Export method wants the exportOptions to be passed, not a boolean.

    Dim wordExportOptions As New ExportOptions()
    wordExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    wordExportOptions.ExportDestinationOptions = dfDestinationOptions
    wordExportOptions.ExportFormatType = ExportFormatType.WordForWindows
    wordExportOptions.ExportFormatOptions = Nothing
   
    rd.Export(wordExportOptions)
Mike King
President - BBSysco Consulting - http://www.bbsysco.com
eMail: mike.king@bbsysco.com

HendersonS

James, I tried it with numerical values, but it still doesn't work.

Mike, I tried passing the object from exportOptions and it's still not working. I think your example uses a different version of Crystal Reports; we're using 8.5. As mentioned before, we used the same logic in PowerShell and it works fine, so we think it should work in pxplus.

PowerShell code Works:
$app = New-Object -ComObject CrystalRuntime.Application
$report = $app.OpenReport("C:\temp\customers.rpt")
$report.EnableParameterPrompting = $false
$report.DisplayProgressDialog = $false
$report.DiscardSavedData() | Out-Null
$exportOpts = $report.ExportOptions
$exportOpts.DestinationType = 1
$exportOpts.FormatType = 31
$exportOpts.DiskFileName = "C:\temp\customers.pdf"
$exportOpts.PDFExportAllPages = $true
$report.Export($false)

Pxplus code Fails:
DEF OBJECT CR_APP,"CrystalRuntime.Application"
 LET REPORT=CR_APP'OPENREPORT("C:\temp\customers.rpt")
 LET REPORT'ENABLEPARAMETERPROMPTING=0
 LET REPORT'DISPLAYPROGRESSDIALOG=0
 LET DS=REPORT'DISCARDSAVEDDATA()
 LET EXPORTOPTS=REPORT'EXPORTOPTIONS ! Opts Object EXPORTOPTS
 LET EXPORTOPTS'DESTINATIONTYPE=1
 LET EXPORTOPTS'FORMATTYPE=31 ! pdf
 LET EXPORTOPTS'PDFEXPORTALLPAGES=-1
 LET EXPORTOPTS'DISKFILENAME$="C:\temp\customers.pdf"
 REPORT'EXPORT(0)