Default value for a collection that is from a query

I know how to create default values for a collection parameter that is used in a list of values input control.  Works fine.

But I can not get that to work when the input control is from a query (a stored procedure in this case).  Any clues?

My parameter is a collection.  I have tried, unsuccessfully, using the following for the Default Value Expression:
new ArrayList(Arrays.asList("value1","value2","value3))
new ArrayList(Arrays.asList(new String [] {"value1","value2","value3}))

In JS Studio, the default values show up.  But not in JS Server.

I have to believe it seems from the input control being a query.

Any suggestions?


mwarner_2's picture
Joined: Jul 10 2015 - 1:17pm
Last seen: 5 years 10 months ago

After more experimenting, I have discovered more about this "problem".  Let's call this parameter (for which I want to have default values) Employee_Types.

The query populating the collection values for Employee_Types is dependent on another parameter value being entered by the user.  Say this other parameter is Customer_Number.

When I enter a default value for the Company_Number (in JS Studio), publish and then run the report, then there are pre-selected choices for Employee_Types.
But If I change the Company_Number, then click off of that field, none of the the Employee_Types are pre-selected.

So when a new Company_Number is entered, then the default values are no longer considered (even though the query for Employee_Types is being run again).

mwarner_2 - 7 years 7 months ago

2 Answers:

I also had to figure this out. So my default values for multiselect inputs look something like this: '(java.util.Collection)(Arrays.asList(1,2,3))' with java.util.Collection as the class and java.lang.Integer as the nested type. Those represent the pk for the field we're comparing to. Then when setting up the input in Jasper Server I'll add label and value so it shows the description but compares the ids. Hopefully this answers your question... If you question was how to use a query to set the default value of an input then I can't help because that is what I'm trying to figure out now

srang's picture
Joined: Oct 28 2014 - 11:52am
Last seen: 7 years 1 week ago

srang - Appreciate your effort.  But it didn't work for me.

For this parameter, these are the values I tried:
Class: java.util.Collection
Nested Type Name: java.lang.String
Default Value Expression - (java.util.Collection)(Arrays.asList("abc","mno","xyz"))  (well not exactly those values)

But after publishing to JS Server, running the report, those values are not pre-selected.

Does it matter that not all the default values are in the values returned by the input control's underying query?

mwarner_2's picture
Joined: Jul 10 2015 - 1:17pm
Last seen: 5 years 10 months ago