Jump to content

How to pass date parameter in XML while scheduling from rest_v2?


Recommended Posts

HI, I passed my date parameter in XML. Selected date is also appearing normal in JasperServer Report Schedule List. But when the report is generated, date filter is not applied correctly, my report shows blank. Now when I manually save that schedule from UI, then my report is scheduling fine and filled up with data. It seems like while clicking on 'Save' button, 'Something' is happening which is not happening while scheduling from web servicies. I am even seeing date in the report, but data is not coming. Please help.

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

The JSON Date parsing uses Dates ISO 8601 format by default.  If you are not sure what format your report input Date parameter is using, our recommendation is:

1) schedule a report job in the web UI with Date selection;

2) run a web service GET request to view this job definition;

3) review job definition to see how the date parm is formulated;

4) use similar Date parameter format to run a web service PUT request to schedule your report job

Hope this helps.

Link to comment
Share on other sites

I created a schedule from web UI. It shows me the below format (dateTime - ISO 8601) .

    <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xs="http://www.w3.org/2001/XMLSchema"


I am also using the same format in the request, even I am getting date printed in Page Header in output report.

But that parameter is passed into a table datasource, and that table is not appearing in the report (empty datasource).

Now if I re-Save the schedule from web UI which I have created through web service, then I can see that table filled with data in the report...

My start_date parameter type in the report is java.util.Date.

...also it doesn't matter whatever the xsi:type I input (date,time or dateTime), job definition always consider it as a dateTime format.

Link to comment
Share on other sites

Thanks a lot tchen.


Sorry, its my mistake. date is passing fine. The issue is multi-select query in input control. we need to pass collection for such input control. Below is my XML code.





This code works fine. Schedule runs fine. report is filled with table and its data. But that 'multi-select-query input control' is not mandatory field for the report. So the issue occurs when collection is empty (means I want to pass empty collection). At that time its passing null. which is creating problem at schedule time...


Now when I re-Save that schedule from web UI, then it converts that null into an empty collection for that input control. So after re-Saving, schedule runs fine, report is filled with table and its data....



So now the real question is...

How to pass an empty collection (for multi-select query input control) through XML?


FYI: I'm using JRS 6.0.1.

Link to comment
Share on other sites

Its not working. I have already tried that. If I do it like this, it shows me null(not empty collection) in the report.

But if I save the schedule from web UI selecting none from that input control then in the report, parameter shows [], which is correct (empty collection) according to JRS.



1) create one report with one parameter having Parameter Class: java.util.Collection

2) put textfield to print the value of that parameter in Page Header (or somewhere else)

3) Now create a multi-select-query input control in JRS

4) deploy the report in JRS, add that input control in the report

5) schedule the report with your sample code (with no item in value tag) and see the value of the parameter ( ...shows null )

6) And then schedule the report again from web UI and check the value of the parameter. (...shows [] )



Link to comment
Share on other sites

Although there are discrepancies on collection parm setting for report job created between JRS web UI and REST_V2 put when no input selection is made , JRS will treat null collection and empty collection the same, as long as report is either created by ad hoc designer or user is using $X{} in the report SQL query. No selection on a collection input when report unit is executed in JasperReports engine means select all for that collection parm.

If using report query with "select * from table where field1 IN $P{collection}", use will need to handle both null and empty conditions for $P{collection} to make the report query work.

I will file a bug report to address this discrepancy in REST report job and thanks for bringing this issue to our attention.

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