passing main parameter to sub-datasets with JasperStudio

11

I'm created a report with JasperStudio 5.5 that have many parameter defined in the main and a lot of sub-dataset (defined with tables) that required this parameters.

The situation:

/main/Parameters: myPar

/main/mySubDataSet1/
/main/mySubDataSet2/
...
/main/mySubDataSetN/

The sub-dataset need to use this parameter in her query: select * from Tab t where t.attr = $P!{myPar}

So, my problem is that the sub-dataset can't access at this main paramenter, all the time that i try compiled, the program send me "Parameter not found : myPar".

How i can do for use myPar in the sub-dataset?

p.s.: i read this thread Pass main dataset parameter to subdataset query (based on iReport) but without success...

cek.i06go's picture
Joined: Dec 24 2013 - 9:00am
Last seen: 4 years 6 months ago

1 Answer:

32

Parameters are attached to the dataset, if you expand the dataset itself, you'll find a section there for parameters, just like in your main report.

You'll need to link the parameters together though, using the connection properties where you're actually using the dataset, eg, in a chart or a table. For example, in the table, you go to the dataset tab of the properties pane, and click on the parameters button to map the parameters between your main report and your sub dataset.

 

cameron_1's picture
836
Joined: May 5 2013 - 8:32pm
Last seen: 1 year 8 months ago

works a lot!!! thx :)

cek.i06go - 5 years 2 months ago

Thanks a lot Cameron, you are a life saver :)

feroxneto - 5 years 1 week ago

This was the best reply I've seen so far! Saved me tons of time.

max_max_mir - 4 years 10 months ago
show 14 more...

Thanks , it works

bit.mind.100 - 4 years 5 months ago

Any idea how to do it with JS studio 6.0, it does not have the Parameters button

shachar - 4 years 1 month ago

It's in the same location in Jaspersoft Studio 6 as it was in 5.5/5.6.

cameron_1 - 4 years 1 month ago

Thanks GURU.............. Lot of Thanks.................

chirag_chaudhari4112 - 3 years 1 month ago

Just what I needed, thanks

catahojda - 3 years 1 week ago

For do this with charts, make the follow steps:

1) Create new parameter on sub-dataset to receive the value from main dataset of report. Uncheck "Is for prompting" option;
2) On "Chart Wizard" window, click on "Parameters" button to open window to map the parameters: http://community-static.jaspersoft.com/sites/default/files/images/Jasper...

diegoqueres - 3 years 20 hours ago

Thanks

thiruna012 - 2 years 7 months ago

many thanks cameron_1 :D

setyo.001 - 2 years 6 months ago

It Worked. Was wondering where I went wrong.
Thanks a lot

ananyachoubey18 - 2 years 5 months ago

I want to thank you about this hint, i was stock in the same problem...thanks again!

jaime.pegueroles - 2 years 3 months ago

Dude, i think you might miss one detail, i add this part to complement your answer. When we are going to add the parameter in the window "Dataset Parameter" a new window comes, in that window we must select the parameter we want to made the relation with the main parameter of the main report, but we must dont forget below there another option "Parameter Expression", we need to add the parameter here to, is mandatory to make this works, so take this part very carefully, hope this can halp to another person.

jaime.pegueroles - 2 years 3 months ago

thanks a lot Camerron_1!! you are special.

r.okuda - 2 years 2 months ago

I agree with max_max_mir....the best, simplest reply so far. Thank you!

jowens_1 - 12 months 1 day ago

Wondering if anyone has a solution to this. I have a parameter for "Academic Year" which is a string value of, for example '2017-2018'. This needs to be passed to subdatasets as a string for use in query WHERE clauses. However, it is being "evaluated" when passed so that it resolves as '-1'. I've tried the $P! convention when referencing both the report parameter and the table dataset parameter to no avail. Any suggestions?

bruce_little - 8 months 2 weeks ago
Feedback
randomness