cancel
Showing results for 
Search instead for 
Did you mean: 

Opening a Crystal Report with parameter value supplied by the user

Former Member
0 Kudos

Hi,

I have a crystal report with a parameter. I want to open this report in JSP with the parameter value supplied by the user. Basically these are the 2 steps:

1) When user try to open the report, a parameter window opens asking for user to enter value and press ok.

2) On pressing ok, the report will show using the parameter value user supplied.

The Step 1 is done and parameter window opens asking me to enter parameter value. When I enter parameter value and press ok, the parameter window opens again asking me to enter parameter value again. This is the code:

ReportClientDocument clientDoc = new ReportClientDocument();

clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);

clientDoc.open(reportName, OpenReportOptions._openAsReadOnly);

CRJavaHelper.changeDataSource(clientDoc, userName, password, connectString, driverName, JNDIName);

CRJavaHelper.logonDataSource(clientDoc, userName, password);

CrystalReportViewer crystalReportPageViewer = new CrystalReportViewer();

crystalReportPageViewer.setReportSource(clientDoc.getReportSource());

crystalReportPageViewer.processHttpRequest(request, response, application, null);

I can run the reports without parameter perfectly. Its only the reports with one or more parameters which are having problems. Is there something missing? Somehow CRJ (Crystal Reports Java) is not using the parameter value entered by the user.

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

After I input values in the parameter window and click OK, I was expecting Crystal report to set those values to the parameters in the report and run the report and show me the report. So I was expecting that this piece of code will be set by Crystal Report:

ParameterFieldController parameterFieldController = oReportClientDocument.getDataDefController().getParameterFieldController();

parameterFieldController.setCurrentValue("", "ID", new String ("1"));

If its not possible then I need to know how can I get values from the parameter window, after user has input those value in the parameter window and click OK.

Adam_Stone
Active Contributor
0 Kudos

Did you even look at my suggestion?

Adam_Stone
Active Contributor
0 Kudos

You may want to look at the sample applications that are available online.  You will see that the ReportSource object is stored in HTTPsession.  Most actions within the Viewer (including the parameter screen) cause postbacks to the server that you must handle.  Most of the samples handle this by simply storing the ReportSource in session, and having a separate jsp page that grabs the object from session and sets the reportsource of the viewer.

Currently your code is reopening the report on each postback which can cause multiple issues.

Former Member
0 Kudos

Since the report expects some parameters, try to set the parameters' values before rendering the report.

Here is a snippet code:

oReportClientDocument.open(reportName, 0);

         

ParameterFieldController parameterFieldController = oReportClientDocument.getDataDefController().getParameterFieldController();

parameterFieldController.setCurrentValue("", "ID", new String ("1"));

Thanks

Alphonse