Writing Code
 Crystal Reports Forum : Crystal Reports .NET 2003 : Writing Code
Message Icon Topic: .NET questions Post Reply Post New Topic
Author Message

Joined: 05 Feb 2014
Online Status: Offline
Posts: 85
Quote hello Replybullet Topic: .NET questions
    Posted: 12 Mar 2020 at 5:02am

I was hoping there where a few .NET gurus here that could help me understand some basic programming using the CRYSTALDECISIONS.SHARED and CRYSTALDECISIONS.ENGINE assemblies.

First off, here is my Powershell code to load a report, set parameters, and then displays the parameters for viewing on the screen.


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

#hard code prompted values here
$customer = '065447'
$location = 1000
$locationsToExclude = 0
$range = New-Object CrystalDecisions.Shared.ParameterRangeValue
$range.StartValue = 1
$range.EndValue = 999

#main report parameter mapping

#sub reports parameter mapping


#$parameterField = New-Object CrystalDecisions.Shared.ParameterField

foreach ($parameterField in $report.DataDefinition.ParameterFields)
        write-output "The current value of:"
        write-output "In report:"
        write-output "is:"
        write-output "Of kind:"
        write-output "-------------------"

What exactly does HASRECORDS do? If I leave out that line, the report has no data and is blank. Is HASRECORDS basically an 'execute' command?

The FOREACH loop at the end simply shows parameter values for each parameter, but the parameters on the sub report never show anything. How do I access the values of the sub reports?

Thanks for any input.
IP IP Logged
Admin Group
Admin Group

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3678
Quote hilfy Replybullet Posted: 20 Apr 2020 at 5:47am
I haven't done this in Power Shell, however, I hope I can point you in the right direction.

1. I would replace "HasRecords" with "Refresh" to run the report.

2. To get to the parameters for the subreport, you actually have to walk through the sections of the report in code to find the subreports and pull the parameters from individual subreports just like you're doing for the main report. In fact, I'm surprised your report is even running because I don't see where you're setting the credentials for the database connections, which you also have to do for each subreport as well as the main report.

IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

This page was generated in 0.031 seconds.