Jump to content
We've recently updated our Privacy Statement, available here ×

How do I pass a parameter to a sub-dataset?


gparker
Go to solution Solved by Thomas Zimmer,

Recommended Posts

I have a report with a number of tables in it. I want to use a Date parameter I setup in the main report section in the queries of the sub-datasets for the tables.

I've tried adding a parameter to the sub-dataset, then adding that parameter to the table, using the parameter in the main report as the default expression, but when I run a preview, it tells me it can't find the parameter in the main report.

I've also tried mapping the paramter to the table, but that results in a ClassCastException error.

I've attached the report below (it's a pretty basic report, as I'm a beginner at this). The only sub-dataset I've put a parameter in so far is "trial." The parameters are "runDate" in the main report and "runTimeDate" in the sub-dataset. The first table, titled "trial," is the one I've been testing this with. I think the query in the dataset has the reference to runTimeDate still in it. I've changed it a number of times, just trying to get it recognized, let alone run.

Thanks for any help!

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

  • Solution

The parameter "runDAte" in your main report is of type java.sql.DAte. The subset's parameter "runTimeDAte" is of type String, change the former and you'll succeed.

You won't have to set a default value for the dataset's parameter, as you pass an actual value in the table within you use that dataset :-)

Cheers, Thomas

http://www.thomaszimmer.net

Link to comment
Share on other sites

I'm still getting the following error - Parameter not found : runDate. I have both parameters as the same type, java.lang.String. The dataset's parameter doesn't have a default value, since it would be getting it through the table itself, if I understand the second part of your answer correctly. I removed the default value for the main parameter as well, since it should prompt for the date. Things seem to be in place, but it still doesn't work.
Link to comment
Share on other sites

Worked it out. The parameter names need to be the same. This apparently tricks the compiler into thinking that there is only one parameter. I'm pretty sure this is an XML issue, since the subDatasets (and therefore, the subDataset's parameters) get called before the main parameters, which doesn't make any sense to me. Maybe there's some reason for that, but I don't see it yet. Thanks again for the help!
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...