Jump to content
We've recently updated our Privacy Statement, available here ×

How to pass string into $X{IN} using URL?


manshack_one
Go to solution Solved by manshack_one,

Recommended Posts

I'm trying to run a query in my report that includes a "where columnname IN (1,2,3)" by using "$X{IN,columnname,parametername}".  I created a parameter in Jaspersoft Studio as a collection.  Once I publish the report to JasperServer then I know I'm supposed to create an input control on the server that matches the name of the report parameter.  My problem though is from what I've read I'm supposed to create a multi-select input control however when I'm creating the control the dialog wants you to select a data type or list of values right then and I don't know what to tell it to use.

Also, what format should my string be in that I'm passing to the $X{} parameter in my URL report call?  (1,2,3) or leave off the parenthesis?  I can build the string pretty much any way I need to.  Right now everything I throw at it is not being recognized so the query builder uses 0=0 for my $X{IN} clause and pulls everything in the tables.

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Posted Images

Create the input control using studio. The input control id should be same as the parameter name. 
For multiselect, you can either chose a list of value or pass a query using which the input control will be populated from the db.

 

EDIT (ON september 29th):

Since you have gladly marked your own answer right I am commenting here.

let me warn you that conditional parameter method that you have used will give you an issue. What if the user hasn't selected any value.

Your IN condition will look something like;

"Where p_para IN ();"

Which is surely bound to give an error. 

But using a collection parameter (& multi select input control), in such a case would replace the whole string with;
"Where 0=0"

Choice is yours.

 

Link to comment
Share on other sites

I'm following along with you but I'm at this point in studio creating the input control.  I've named it the same as the parameter in the report itself.  However, since this input control is not going to be visible (because I want to use the http repository api) the user will never have the option to enter the values.  The values will come from the URL string I'm building inside my application.  So what do I use at this point to get Server to let me use a multiselect without creating the list of values at this point?

 Clipboard02.jpg.7f3091e69af59a912041a1112ea57d05.jpg

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