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

0

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.

jigar.patel's picture
Joined: Jan 30 2015 - 12:21am
Last seen: 3 years 7 months ago

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.

tchen - 4 years 8 months ago

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

<entry>
    <key>start_date</key>
    <value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xsi:type="xs:dateTime">2015-02-01T00:00:00+05:30</value>
</entry>

 

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.

jigar.patel - 4 years 8 months ago

3 Answers:

0

Which version of JRS are you using? I need to run some tests to see what is going on here.

tchen's picture
52698
Joined: Feb 27 2008 - 7:33am
Last seen: 3 hours 14 min ago

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.

<entry>
<key>Region</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="collection">
<item xmlns:xs="http://www.w3.org/2001/XMLSchema" xsi:type="xs:integer">34</item>
</value>
</entry>

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.

jigar.patel - 4 years 8 months ago
0

You don't need to pass any items if the collection contains no selected values:

<entry>
<key>Region</key>
<value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="collection">
</value>
</entry>

tchen's picture
52698
Joined: Feb 27 2008 - 7:33am
Last seen: 3 hours 14 min ago

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.

You,
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 [] )

Thanks...

jigar.patel - 4 years 8 months ago

Alternative solution is passing parameter value to another parameter and putting condition to check null before assigning value.

jigar.patel - 4 years 8 months ago
1

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.

tchen's picture
52698
Joined: Feb 27 2008 - 7:33am
Last seen: 3 hours 14 min ago

Thanks for the meaningful conversation. Good Experience. :)

jigar.patel - 4 years 7 months ago
Feedback
randomness