cancel
Showing results for 
Search instead for 
Did you mean: 

Setting parameters programmatically, saved value of parameter always used

Former Member
0 Kudos

Hi,

I have downloaded the trial version of Crystal Reports and Crystal Reports Server and created reports which are now in the Repository. The reports have static parameters.

In Eclipse I have set up my development environment, copying C:\Program Files\Business Objects\Common\4.0\crystalreportviewers12 to my WebContent folder, copying jars to the lib directory and editing the web.xml (there are a number of errors in the jsp's due to webreporting.jar not having the CrystalReportInteractiveViewer class, nor the reportsourcebridge.jar).

I now have to set the parameters for the reports programmatically.

I have been using the ReportClientDocument to set parameter values, as discussed by Ted Ueda in his post of March 11 ("How can I set prameters on a report source").

However the report displayed then seems to ignore these parameters and always uses the values the report was first saved with in the repository. Below is the code being used:

ISessionMgr sessionMgr = CrystalEnterprise.getSessionMgr();

enterpriseSession = sessionMgr.logon(userID, password, CMS, auth);

CrystalReportViewer viewer = new CrystalReportViewer();

int reportId = 1997;

IReportAppFactory reportAppFactory = (IReportAppFactory) enterpriseSession.getService("RASReportFactory");

ReportClientDocument reportClientDoc = reportAppFactory.openDocument(reportId, 0, request.getLocale());

Fields f = reportClientDoc.getDataDefController().getDataDefinition().getParameterFields();

System.out.println("Fields, size: " + f.size() + ", " + f.toString());

ParameterField pField = (ParameterField) f.getField(0);

Values values = new Values();

values.add(9000);

pField.setCurrentValues(values);

pField.setDefaultValues(values);

System.out.println("Fields, size: " + f.size() + ", " + f.toString());

// reportClientDoc.refreshReportDocument();

reportClientDoc.save();

viewer.setReportSource(reportClientDoc.getReportSource());

viewer.setDisplayPage(true);

viewer.setDisplayToolbar(true);

viewer.setOwnPage(true);

viewer.setOwnForm(true);

viewer.setName("My Simple Employee Report");

viewer.setEnableParameterPrompt(true);

viewer.setEnableLogonPrompt(true);

viewer.refresh();

viewer.setURI(request.getRequestURI() + "?ReportID=" + reportId);

viewer.processHttpRequest(request, response, getServletContext(), null);

viewer.dispose();

As such I presume I am using the RAS Server. not the Page Server.

When run the report always displays with the values it had when saved in the repository, i.e. the parameter value that I used when I saved the report in the repository is used. I added to "viewer.refresh()", and as a result of this I am prompted to logon to the database. However the current values in the database are not displayed.

Once the report id displayed in the browser, if I then use the viewer in the browser to set and apply a new value for the parameter and click "Apply", then that new parameter value applies and the current values from the database are displayed.

Any help on what I am doing wrong greatly appreciated, I need to have the initial display of the report use a parameter value supplied by the user.

Regards

Mark

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Use

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

parameterFieldController.setCurrentValue("", ParameterName, ParameterValues);

Hope it will help!

Thanks

Saravanakumar.

Former Member
0 Kudos

Thanks very much, that solved my problem.

It makes me wonder why the documentation supplied is so confusing!

Regards

Mark

Answers (0)