Jump to content
JasperReports Library 7.0 is now available ×

Trouble Passing a Input Control Parameter Value in a Query as String


knoxcorr

Recommended Posts

We are just starting the process of converting to Jaspersoft from BOXI for our CA Service Desk Manager installation and I am working on converting my existing reports but have run into some issues using input controls.

I copied an out of the box report into a customer folder and it works normally, however, if I add an OOTB input control and add the same WHERE clause (cr.group_name in $P!{p_group}) used on another OOTB report with that input control to my query, it does not work.

I was able to get it to work if I change the input control to a single-select query and change the WHERE clause to cr.group_name = '$P!{p_group}' then I can get the query to work. It seems that my biggest issue is that the string values do not have quotes surrounding them. 

I have tried changing the multi-select version to $X{IN, cr.group_name, p_group}, but then the query just shows ? for the value of the input control. Or if I use the option that works for the single-select, cr.group_name IN '$P!(p_group', I end up with a result in the query like: cr.group_name IN '[value1, value2]'

I feel like i must be missing something simple as this shouldn't be hard.

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

After quite a bit of stumbling around and reviewing the OOTB reports, I found out what I was doing wrong.

The actual report needs to be a sub-report of the main report. On the main report, you have to add a variable to string the parameter together with the proper syntax, like:

"('"+org.apache.commons.lang.StringUtils.join($P{p_group}.toArray(),"','") + "')"

Then you have to pass the parameter to the sub-report with this variable as the parameter expression. As long as the parameter is set up as Class Type: java.util.Collection and Nested Type Name: java.lang.String in the main report, and then as Class Type: java.lang.String in the sub-report, this works correctly  the Where clause I was trying to use.

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