GonzaLinares Posted May 4, 2018 Posted May 4, 2018 I´m using Jaspersoft Studio 6.5In a new report, i want to do some operations with parameters before the query is executed and brings report dataFor example, as a parameter i ask user to insert a date.I want to calculate days passed from that date. Then pass those days to seconds and use those seconds in the query.Is there anyway to do this?A workaround i thought that may work was to create a new parameter, and do not promp it.In it expression, do the operations and then use that parameter in the query. By doing this, i use this 2nd parameter as a "function" that operates with the parameter1st Parameter:Name: dateParamType: java.util.DateDefault Expression: -Is For Prompting: Checked2nd Parameter:Name: secondsParamType: java.lang.LongDefault Expression: new org.joda.time.DateTime($P{dateParam}).getMillis()/1000Is For Prompting: Not checkedBoth of them have Early evaluation time.Then in the query i use 2nd parameter. i.e ... WHERE P${secondsParam} > ticketTable.openDateSeconds After doing this, it actually work in Jaspersoft Studio. But when trying to execute it on JaspersoftReports Server, 2nd parameter don´t take 1st parameter value.
hozawa Posted May 7, 2018 Posted May 7, 2018 Have you tried custom functions?https://community.jaspersoft.com/questions/1085241/how-publish-custom-functions-jasper-studio-jasper-server
Solution riodavid Posted May 11, 2018 Solution Posted May 11, 2018 I think you can re-write the logic of the 2nd parameter to SQL, and implement it in Input Control. That's how cascading input control works.
GonzaLinares Posted May 11, 2018 Author Posted May 11, 2018 Finally find a solution.Did something similar to what you said.Created a input control asking for the date. Then used 2nd parameter to convert value in the input control.I guess all parameters have same evaluation time, but input controls have an earlier evaluation time.Hence, 2nd parameter does take value from 1st parameter(At least at Jaspersoft Server, since it worked with 2 parameters in Jaspersoft Studio)
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