Previous Page Next Page
Using Dynamic Resources and Local Parameters in Reports
Creating and using dynamic formulas
Creating and using dynamic aggregations
Creating and using local parameters
When working with reports that are created using business views, sometimes you may find the predefined view elements in the business views the reports use, or the predefined parameters in the current catalog cannot meet your requirements. In this case, you can create dynamic resources (including formulas and aggregations) and local parameters and use them in the reports to get the desired data. Then when you save the reports, the dynamic resources and local parameters will be saved along with the reports as their resources in the report files.
Dynamic resources and local parameters are report level resources, which means they are only available to the report for which they are created. Unless you need to use the formulas, aggregations or parameters in multiple reports, it is always better to create dynamic resources and local parameters rather than create them in the catalog.
Creating and using dynamic formulas
To create a dynamic formula:
- In the Data panel of the main window expand the Dynamic Resources > Formulas node and click <New Formula…>, or in the report wizard or dialog where a dynamic formula list is provided, click <New Formula…>.
- In the displayed dialog, specify the name of the formula and click OK.
- In the Formula Editor, create the formula according to your requirement.
- By default, JReport will decide whether the formula can be used as an aggregation object, and if not the formula will be used as a detail object. You can specify to use the formula as a detail, group, or an aggregation object, by selecting the corresponding view element type from the Use As drop-down list on the toolbar.
Whether a dynamic formula can be used as a certain type depends on the following rules:
- Any formula can be used as Detail.
- Any formula that references a DBField and not an aggregation can be used as Group.
- A formula that refers only to aggregations can be used as Aggregation. For example, there are two aggregations Sum_Total and Sum_Quantity, and you can create a formula
@"Sum_Total" / @"Sum_Quantity"
and use it as an aggregation.
- A formula that follows the custom aggregation expression can be used as Aggregation.
- Save the formula and exit the Formula Editor.
Once a dynamic formula is created, you can then drag it from the Data panel to the desired position in the report, or add it as report field when working with the report wizard.
In the Data panel, you can make use of the shortcut menu of any existing dynamic formula to edit or delete the formula, or change the formula type as Group, Detail, or Aggregation if needed. Dynamic formulas that have been used in the report cannot be deleted.
Notes:
- You can only use JDK (not JRE) to compile formulas created in JReport and save a dynamic formula with no errors into a report.
- Currently, global variables are not supported in dynamic formulas.
- When dynamic formulas reference display names or mapping names, the names should not contain any of the following characters if the names are not quoted by double-quotation marks "":
"~", "`", "!", "@", "#", "$", "%", "^", "&", "*", "(", ")", "-", "+", "=", "{", "}", "[", "]", "|", "\\", ":", ";", "\", " ' ", "<", ",", ">", ".", "?", "/"
Examples:
- Expression @Customer#; will cause a syntax error. But @"Customer#" is ok.
- If a field has the display name Category.Aggregation, when adding it to a formula, quote it as "Category.Aggregation" or "Category"."Aggregation".
Creating and using dynamic aggregations
To creating a dynamic aggregation:
- In the Data panel of the main window, or in the Resources box of the report wizard, expand the Dynamic Resources > Aggregations node, then click <New Aggregation…>. The New Aggregation dialog appears.

- In the Aggregation Name text box, specify the name of the dynamic aggregation.
- Click
next to the Mapping Name text box to specify the field on which the dynamic aggregation is based.
You can map dynamic aggregations to the available resources such as group objects and detail objects in the current business view, or the dynamic formulas that have been created in a web report.
- From the Aggregate Function drop-down list, specify the aggregate function.
- When done, click OK to create the dynamic aggregation.
Once a dynamic aggregation is created, you can then drag it from the Data panel to the desired position in the report, or add it as report field when working with the report wizard.
In the Data panel, you can make use of the shortcut menu of any existing dynamic aggregation to edit it in the Edit Aggregation dialog or delete it. Dynamic aggregations that have been used in the report cannot be deleted.
Creating and using local parameters
- In the Data panel of the main window, or when specifying the value of a filter condition for a data component created using a business view with the Format Filter dialog, click <New Parameter…> in the Local Parameters node.
- In the New Parameter dialog, create the parameter according to your requirement.
- Click OK to create the parameter and exist the dialog.
Once a local parameter is created, you can then use it to dynamically filter data of the data component in the report, add it to a parameter control or parameter form control in the report, or reference it in a dynamic record level pass one formula used in the report.
In the Data panel, you can also make use of the shortcut menu of any existing local parameter to edit or delete it. Local parameters that have been used in the report cannot be deleted.
Previous Page Next Page