I am using the CrystalReportViewers12 in my Apache Tomcat web-application. I have got the report to be fully functional and am even able to pass parameters to the Report. But when attempting to pass a parameter value to the sub-report I receive the following error:
ReportSDKParameterFieldException: Some parameters are missing values---- Error code:-2147217394 Error code name:missingParameterValueError.
I should mention that the parameter in the Sub-Report is linked to a field on the Main Report.
Here are the two methods I attempted to utilize to set the sub-report parameter value but to no avail.
//I know this method works for adding Parameter values to the main report
1. Fields parameterFields = new Fields();
ParameterField paramField = new ParameterField();
ParameterFieldDiscreteValue paramFieldDiscreteValue = new ParameterFieldDiscreteValue();
Values paramValues = new Values();
paramFieldDiscreteValue.setValue("PARAM_VALUE");
paramValues.add(paramFieldDiscreteValue);
paramField.setName("P_PARAMETER_NAME");
paramField.setCurrentValues(paramValues);
parameterFields.add(paramField);
parameterFields.setReportName("SUB_REPORT_NAME");
viewer.setParameterFields(parameterFields);
2. ReportClientDocument clientDoc = new ReportClientDocument();
clientDoc.setReportAppServer(ReportClientDocument.inprocConnectionString);
clientDoc.open("REPORT_NAME", OpenReportOptions._openAsReadOnly);
IStrings subNames = clientDoc.getSubreportController ().getSubreportNames ();
for (int subNum = 0; subNum < subNames.size (); subNum++)
{
DataDefController dataDefController = clientDoc.getSubreportController().getSubreport(subNames.getString(subNum)).getDataDefController();
Fields paramFieldd = (Fields) dataDefController.getDataDefinition().getParameterFields();
clientDoc.getDataDefController().getParameterFieldController().setCurrentValue(subNames.getString(subNum),paramFieldd.getField(subNum).getName(), 0);
}
At this point I'm a bit stuck and would appreciate any help.
Thanks.