Jump to content
Changes to the Jaspersoft community edition download ×

wants to return all value of list but its returning only the last value


nahian35

Recommended Posts

In main report I have A,B,C three field, I passed value of A to sub report variable using a parameter and calculate it with a value then return it to main report variable B. Everything is working fine but the problem is: its returning only the last value of list in B. I want full list in B. How can i solve it ?

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

In you sub report, when you drag variable B onto the detial band, does it generate multiple values row for row? (First need to test that variable B is working as expected. You could have a sequence or order issue.

If B is working as expected. Maybe build an array in your subreport with values from B and then pass over the array(parameter) to main.   
First you need to create parameter, let call it Array.
Class java.util.ArrayList
Default Value Exp = new ArrayList()
Untick prompting

Then create Variable: 
Array_add
Value class : java.lang.Boolean
Expression: 
!$P{Array}.contains(B) ? !$P{Array}.add(B) : null    (This ensures no duplications,)
Calculation: No Calc
Increment type : None
Reset Type: Report

Then create 2nd variable: 
Array_build
Value class : java.util.ArrayList
Expression: $P{Array}
Calculation: System
Increment type : None
Reset Type: None

You might need to do some parsing depending on class of your values. 
Then return value to main by mapping your $P{Array} sub to a parameter in main.

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...