Skip to Content
0

Modify a RunningTotal field's EvaluateCondition using the CR .Net SDK

Dec 19, 2017 at 04:57 PM

23

avatar image

I'd attempting to change the EvaluateCondition for a report's RunningTotal fields if the condition matches a certain value:

$path='C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet\iPoint'

Add-Type -Path "$path\CrystalDecisions.CrystalReports.Engine.dll"
Add-Type -Path "$path\CrystalDecisions.Shared.dll"

$reportDocument = New-Object CrystalDecisions.CrystalReports.Engine.ReportDocument

$path = "C:\users\<username>\desktop\report.rpt"

# not sure if i should use
$reportDocument.Load($path)

# or this
$reportDocument.ReportClientDocument.Open($path,0)

$OldValue='foobar'
$NewValue='foobarBAZ'

$reportDocument.ReportClientDocument.DataDefinition.RunningTotalFields | % {

    if ($_.EvaluateCondition -like "*$OldValue*") {
        Write-Debug $_.Name

        # modify the formula
        $_.EvaluateCondition = $_.EvaluateCondition -replace $OldValue, $NewValue
        Write-Debug $_.EvaluateCondition
    }

}

$reportDocument.ReportClientDocument.Save()
$reportDocument.ReportClientDocument.Close()

While the debug messages indicate that the EvaluateCondition was modified correctly, the changes aren't saved to the report (inspecting the running-total fields w/ Crystal Reports). Moreover, the Close() method doesn't seem to actually close the report.

What am I doing wrong?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Don Williams
Jan 30 at 04:38 PM
0

Changed the Tag to Platform SDK.

First, don't browse to the Assemblies, load them from the GAC.

See this page for samples and more info:

https://wiki.scn.sap.com/wiki/display/BOBJ/Getting+started+and+moving+ahead+with+Crystal+Reports+.NET+applications

More info on this WIKI home page:

https://wiki.scn.sap.com/wiki/display/BOBJ

Don

Share
10 |10000 characters needed characters left characters exceeded