Tuesday, May 26, 2015

NextReports: Batch Mode

From version 8.1 users can run/schedule a report in batch mode. What does this mean?
If a report has a single-selection parameter with a source and if this parameter is selected as a "batch parameter" then running it in batch mode will generate a report for every value of that batch parameter.

To make this right there are two conditions that must be met:
  1. Batch parameter must not be set as dynamic
  2. All chained parameters that are children of batch parameter must be set as dynamic.
These two conditions are also written inside batch definition panel and are automatically set on save if user does not do it.

As an example, we use a report that shows the Timesheet for an employee on all projects he is assigned to. There are two parameters : Employee and Work code (work, meeting, administration, travel) so we can see the Timesheet for that employee for a specific list of work codes.


Here we see that the parameter we want to use in batch (Employee) is not set as dynamic, but the other parameter (Code) which is a child of Employee parameter is set as dynamic.

Batch Mode is practically a new step in run/schedule wizard process:


"Employee" parameter was set as a batch parameter. This simple selection means the report will be generated for all "Employee" values.

Second field, called Batch Data Query, is a simple sql select that gives an email address for every Employee. First column in query must be the same as that used in source for Employee parameter, which is defined as:

select distinct employeeid, firstname || ' ' || name as fullName from employee

Second column in query is the email column.

Batch Data Query is needed only if we need to send every generated report to it's actual employee.

Mail Destination Step in this case is allowed to not define a To property, because it is dynamically set at run time:


But we can also select a To property if we also want to send all generated reports to a static email address. In mail step, we can see that besides existing template values until version 8.1 (like ${date}, ${time}, ${name}) we can use parameter values as $P{Employee} or $P{Code}. This allows to have a mail message customized for every employee.

No comments: