crinch Posted August 15, 2012 Share Posted August 15, 2012 Hi I am using JasperSoft 4.5 and have created a report which has two parameters- country_param : takes input from user- country_param_qry : checks first parameter's value and manipulate the query accordingly. e.g; i have set its [default value expression] like this.($P{country_param}!=""?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")the QUERY is like this============query==================== SELECT sp.OrderId, sp.ShippingCountry FROM tblshippedorders sp WHERE sp.PartnerId =$P{parternerId}$P!{country_param_qry} ORDER BY `sp`.`OrderId` DESC====================================This scenario works fine in iReport tool but when I export it in the Jasper server and create these parameteres but it did not work. I think there is need to make association between these 2 parameters in Jasper server report as done in iReport tool using second parameter's [default value expression]Need help to handle thisThanks Link to comment Share on other sites More sharing options...
oesina Posted August 15, 2012 Share Posted August 15, 2012 Hi,Just designed exactly as you described and it works perfectly on JRS.Guess you just did naming mistake around "parternerId" parameter.Look into the server log to understand the message and output your parameter values to the report itself for debugging.Good luck, Olga Link to comment Share on other sites More sharing options...
crinch Posted August 16, 2012 Author Share Posted August 16, 2012 Hi Olga, Thanks for your replry, I have checked the "parternerId" parameter spelling and there is no issue with this. If I use only this parameter and reports works fine in JRS. However when I use "$P!{country_param_qry}" this query then there is problem wit the report.Actually I am trying to making the second input as optional if the user enter the country it will fetch the records against only that country but if the user did not enter the country so all the records will be fetched. So to get the functionality I have created two parameters to manipulate the query. This works fine in iReport tool but when I go in JRS it doesn't work.I am thinking about this line ($P{country_param}!=""?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")the above linke I had set this in iReport tool [default value expression] of the parameter "country_param_qry". Is there something we need to to in JRS against "country_param_qry" parameter to get this funtionality in JRS. WHAT DO YOU THINK.I have also tried to print this parmeter, it prints accurate value in iReport but prints null in JRS. I have attached the screen shot of JRS.Once again, I am really thankful to you for reply.CRINCH Link to comment Share on other sites More sharing options...
oesina Posted August 16, 2012 Share Posted August 16, 2012 Hi Crinch,I think we see the answer in your picture, thanks for including that. Your country_param=null,So thatcountry_param_qry = AND sp.ShippingCountry='null' while you actually want to make it empty. Try ($P{country_param}!=null?" AND sp.ShippingCountry='"+$P{country_param}+"'":"") On the other side you should never have null value for a string in the first place. If the first parameter is empty, your qry expression should work perfect. Maybe you got the default value for your Input Control as null, but it should be just empty. So it's not a problem of second parameter calculating wrongly, but rather first parameter getting wrong value as null. For me it works exactly perfectly:country_param=''country_param_qry ='' country_param='USA'country_param_qry = AND sp.ShippingCountry='USA' Link to comment Share on other sites More sharing options...
crinch Posted August 16, 2012 Author Share Posted August 16, 2012 Hi OlgaThank you for your reply, I have tried your line of code ($P{country_param}!=null?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")even with different combinations like($P{country_param}!="null"?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")($P{country_param}!=NULL?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")==========with the scenario, if the user did not enter country===============First of all using this line, it doesn't run in iReport tool and gives alert message like "The document has no pages". However works fine in iReport tool if the user enters any country. I have still used the above line of code of combinations and export the report in the JRS, like the below one($P{country_param}!=null?" AND sp.ShippingCountry='"+$P{country_param}+"'":"")if the user select country or not, the empty result is returned. I have attached the screen shot which has empty value. Also, when I go to create an input control the 'visible' checkbox every time gets checked and can't be un-selected.I really thankful to you for this.CRINCH Link to comment Share on other sites More sharing options...
militeev Posted October 1, 2012 Share Posted October 1, 2012 I had a similar problem. Turned out that it was because of parameter and input control result having different types. Input control was a query with the returning column of type Integer, and parameter was of type String. When changed parameter type to Integer, the problem's gone. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now