I was recently working on generating pdf for a report deployed in CRM through code using ReportingExecution2005 web service.
While writing the code, we faced a very strange issue where values for certain ReportParameters were not getting passed.
I will try to explain the scenario using a very simple report.
Suppose I have report that has 4 report parameters and I am setting values for only 3 of the parameters through code. (Note:-ReportParameter4 is set as second parameter)
Suppose they all are Boolean parameter with default value as True.
Now I am using the following code to set their values as false.
ParameterValue myPVArray = new ParameterValue;
ParameterValue myPV1 = new ParameterValue();
myPV1.Name = "ReportParameter1";
myPV1.Value = "False";
myPVArray = myPV1;
ParameterValue myPV2 = new ParameterValue();
myPV2.Name = "ReportParameter3";
myPV2.Value = "False";
myPVArray = myPV2;
ParameterValue myPV3 = new ParameterValue();
myPV3.Name = "ReportParameter2";
myPV3.Value = "False";
myPVArray = myPV3;
This is the output of the pdf
i.e. the value appears properly for the ReportParameter 1 to 3 as set as false. For the report parameter 4 it comes as True (i.e. its default value as we are not setting it).
Now I go forward and make a small change instead of specifying default value for ReportParameter 4 as True, I modify it to take the value from the DataSet instead.
And Data Type from Boolean to Text.
Now I run the same code. This time again we would expect the value for ReportParameter 1 to 3 as False and ReportParameter4 to be whatever value there in the DataSet.
However we will get the following pdf output
For Report Parameter 2 and 3 we see the default value (i.e. True) instead of False as we are passing through code.
The solution to this that I found was to move the reportparameter 4 as the last parameter in the report.
Currently in our report it is set as the second one.
The output after running the code
i.e. the one we were expecting.
So one thing we need to remember over here is that if we have any of our report parameter taking its value from dataset then we should make it the last parameter or should put it after all the other report parameters whose value we are passing through code.
Hope it helps.