2.3. Report for a List of Entities Filtered by Query

Now let’s have a look at the last report type suggested by the wizard: the report for a list of entities filtered by a query. To demonstrate this use case, we will complicate the previous example. As before, the report will contain a list of books (with their titles and department names), but only added after a certain date.

Let us set the details of the report like in the previous case:

  • Entity - report entity - library$BookInstance.

  • Template type - output file format - XSLX.

  • Report name - 'Recently added book items'.

Then select the Report for list of entities, selected by query report type.

query step 1
Figure 17. Report for a List of Entities Filtered by Query

The selected report type allows us to select the list of entities that match the specified conditions. In order to set the query, click Set query link below.

The Define query window appears. As you can see, the window is similar to the generic filter window. Here you specify conditions, combine them into AND/OR groups and configure their settings.

In order to add a new query condition, click Add. Select Created at attribute in the appeared window. Now the attribute is added to the query conditions tree and the right-hand side panel displays its properties.

In the properties panel, you can set the default parameter value. If the report logic is not supposed to be changed, you can make this attribute hidden by checking the Hidden checkbox. In this case, the user will not be requested to input this parameter when running the report.

Select an operator (>=).

query parameter
Figure 18. Query Parameter

After saving the query, click Next and move to library$BookInstance attributes selection. We move BookItem.Publication.Book.Name and BookItem.LibraryDepartment.Name attributes to the right. Click OK to move on to accomplish the first stage.

list of entities attributes
Figure 19. Select Entity Attributes

Press NextSave to save the report.

query step 2
Figure 20. Entity attributes

The report will look as follows:

query editor
Figure 21. Report data structure

The editor enables making the report structure more sophisticated by adding new bands and data sets, as well as configuring the report template design, localization, access rights.

For instance, we can switch to Parameters and Formats tab and modify the query parameter in the Parameters list: Date instead of the standard CreateTs1. Save the changes and close the report editor.

query parameter rename
Figure 22. Parameters and Formats tab

After all, let us add the Report button that runs the report right from the library departments browser.

In order to do this, we need to define a button in the librarydepartment-browse.xml screen descriptor:

<table id="libraryDepartmentTable"
    <buttonsPanel id="buttonsPanel">
        <button id="reportBtn"

After that, inject the button in the screen controller:

private Button reportBtn;

and assign RunReportAction to the button in the overridden init() method:

reportBtn.setAction(new RunReportAction("report"));

For each report, add library$LibraryDepartment.lookup to the screens list on the Roles and Screens tab of the report editor, as we did in the previous examples.

The Report button will appear in the library departments browser, displaying the list of all reports available in the system in one click. In order to run the report, select Recently added book items in the list, specify the date and click Run report.

query running
Figure 23. Run report

The output is as follows:

query result
Figure 24. Report result