Parameter with default returing all values

0

 

Hi,
 
I'm using iReport 4.5.0 Community Edition with language set to Groovy and have trouble defining a parameter. The basic thing is that I want to build a default option 'All values' into a parameter and cannot find a way to do it.
 
I have a field HospitalType with values 1 (Central), 2 (Region) and 3 (Local) and some missing values. I want to have a parameter with the options Central, Region, Local and a default value All that includes all three levels. In the last case I'm asking for a range of values and that's where the problem begins. I tried using some tips I found on technical blogs and here but I'm not getting any further.
 
In my Report SQL query I included WHERE $X{IN, HospitalType, TypeParameter}
 
For my parameter TypeParameter I tried Parameter Class: java.util.List and Default Value Expression: java.util.Arrays.asList(NULL,1,2,3) but then I get an error when reading the fields in the Report query: 
 
Error in method invocation: Static method asList(null,int,int,int) not found in class 'java.util.Arrays'
 
Is this the right way to do it, where is the problem? 
 
Many thanks in advance for any help and suggestions.
niels.cadee's picture
Joined: Nov 9 2012 - 5:53am
Last seen: 6 years 6 months ago

1 Answer:

1

I wish I had more time to really spell this out but I think I can give you pointers to look in the right direction.  The parameter is of class Collection with a default value of %.

My report query has this: WHERE

$X{IN, vw_TimeTracker_Oppt.`OppType`, OpptTypeSelect}

Then on the jasperserver I make two controls, one is of type query that defines the holds your actual database query: For example there's this one that shows me all but a few that I don't want to have in a selection.  

SELECT DISTINCT opportunity_type FROM sugarcrm_prod.`opportunities` WHERE NOT ISNull(opportunity_type) AND opportunity_type NOT IN('Existing Business','New Business','Program','Series','Single') ORDER BY opportunity_type

Then you create another control where the type is something like Multi-select query (check box or radio button) then select the query control for the query resource.  On the value and visible columns I select the opportunity type from the above query.

So, I think that adds info on how to present end users with a choice as well as how to limit your return values.

I guess I did have time to explain it :)

Jerry

jvway's picture
146
Joined: Mar 9 2009 - 11:43am
Last seen: 3 years 8 months ago

Thanks ever so much for your time Jerry! I'll try this and also the suggestion I got from Jaspersoft Support: Use Parameter Class java.util.Collection and just leave the Default Parameter Value empty. It seems to work, I'm on the right track now!

niels.cadee - 6 years 11 months ago
Feedback
randomness