Previous Page Next Page
Using Dynamic Resources and Local Parameters
Creating and using dynamic formulas
Creating and using dynamic aggregations
Creating and using local parameters
When you add fields to a report or use parameters to define filter conditions in a report, sometimes you may find that the view elements that have been predefined in the business view or the given parameters in the current catalog cannot meet your requirements. In those cases, you can create dynamic resources (including formulas and aggregations) and local parameters in the report and use them to get the desired data. Then when you save the report, the dynamic resources and local parameters will be saved along with the report as its resources.
Dynamic resources and local parameters are report level resources, which means they are only available to the report for which they are created.
Creating and using dynamic formulas
You should have some knowledge of the formula syntax before you can successfully compose a formula with no errors. To learn the formula syntax, refer to Formula Syntax.
To create a dynamic formula:
- In the Resources panel of Web Report Studio or the Resources box of the Web Report Wizard, expand the Dynamic Resource > Formulas node, then click <Add Formula…>. The Formula Editor appears.

- Enter a name for the formula in the Formula Name text field.
- 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.
- Compose the formula by selecting the required fields, functions and operators from the Fields, Functions and Operators boxes. You can also write the formula by yourself in the editing box.
For details about the functions and operators, refer to Built-in Functions and Operators.
- Click the Check button
to check whether or not the syntax of your formula is correct.
- When done, click the OK button to create the formula.
Once a dynamic formula is created, you can then drag it from the Resources panel to the desired position in the report for data analyzing, or add it as report field when working with the report wizard.
In the Resources panel of Web Report Studio, you can make use of the shortcut menu of an existing dynamic formula to edit or delete the formula, or change the formula type as Group, Detail, or Aggregation if possible.
Notes:
- You can only use JDK (not JRE) to compile formulas created in JReport and save a dynamic formula with no errors into a web report.
- Currently, global variables are not supported in dynamic formulas.
- When 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
In Web Report Studio, you can also create dynamic aggregations by mapping them to the available resources such as group objects, detail objects in the current business view and the dynamic formulas that have been created in the report.
To create a dynamic aggregation:
- In the Resources panel of Web Report Studio or the Resources box of the Web Report Wizard, expand the Dynamic Resource > Aggregations node, then click <Add Aggregation…>. The Add Aggregation dialog appears.

- In the Aggregation Name text field, specify the display name of the dynamic aggregation.
- Click the button
next to the Mapping Name text field. In the Select Resource dialog, specify the field on which the dynamic aggregation is based.
- 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 Resources panel to the desired position in the report for data analyzing, or add it as report field when working with the report wizard. And if you want to edit any dynamic aggregation or delete it, right-click the aggregation and click Edit or Delete on the shortcut menu.
Creating and using local parameters
When you use parameters to compose the filter conditions applied to a report, if the given parameters in the current catalog cannot meet your requirements, you can create local parameters to use in the report. The local parameters created for a report can also be added to the parameter controls and parameter form controls in the report, or referenced in dynamic formulas used in the report.
To create a local parameter and use it in a filter:
- When filtering a business view in the Query Filter dialog, or a data component using the Filter dialog, click the button
and select <Add Parameter…> from the Local Parameters node of the value drop-down list.
The Add Parameter dialog appears.

- In the Name field, input a name for the parameter.
- Select a parameter type from the Value Setting drop-down list. For parameters in XML connection, it can only be Type-in Parameter.
- In the value section, specify the parameter values as required. The section varies with the type you select from the Value Setting drop-down list.
- For Type-in Parameter:
- Specify the data type of the parameter value from the Value Type drop-down list.
- Click
to add a value line, double-click in it and then type in a value of the specified data type.
If the parameter is of Date, DateTime, or Time type, you can also click the calendar button
to set a date and time value using either calendar or expression functions in the Calendar dialog. If you use an expression to specify the value, when you hover the mouse pointer over this value, a tip will appear showing its expression. Click on the value, the expression will be displayed in the value text box and you can edit the expression in the text box directly if you want. After editing, when you click elsewhere outside of the value text box:
- If the edited expression is correct, a new value calculated by the expression will be displayed in the parameter value text box.
- If the edited expression is wrong, no value will be created and the expression itself will be displayed and highlighted in red in the value text box. Correct the expression, or click the calendar button to specify a value.
- Repeat the above step to add more values.
To adjust the order of the values, click
or
; to remove any unwanted value, select it in the list and then click
.
- To make a value the default selected value for the parameter, select it from the list.
- For Bind with Single Column
JReport provides a mechanism that links each value of the display DBField with the exact value of the bound DBField, so that when you select a value of the display field, the value of the bound field is actually sent to the query and filters the query result. This can help you bind the parameter to a DBField in order to provide a list of values for the report users to select which probably makes more sense. The selected value of the bound field will be used as the parameter value. For example, it might be confusing if you provide a list of customer ID numbers for the report users to select, since the ID numbers would probably mean nothing to them. In cases like this, it is better for you to display values of other fields, which would make more sense. For this case, you might prefer to display customer names instead of ID numbers. When the report users select a customer name from the list, its ID number is passed to the query as the parameter value so that the search criteria can be fulfilled.
- From the Source drop-down list, select the required business view in the current data source from which to get data for the parameter. All the group and detail objects in the specified business view will be available for retrieving values for the parameter.
- Select a field from the Bind Column drop-down list. This field is used to filter the query when running a report with the parameter.
- If you want the values of another field to be displayed for the report users to choose from, select that field from the Display Column drop-down list.
JReport provides a mechanism that links each value of the display field with the exact value of the bound field for a parameter, thus when you select a value of the display field, the value of the bound field is actually sent to the query and filters the query result. This can help you bind the parameter to a DBField in order to provide a list of values for report users to select which probably makes more sense. The selected value of the bound field will be used as the parameter value. For example, it might be confusing if you provide a list of customer ID numbers for users to select at runtime, since the ID numbers would probably mean nothing to them. In cases like this, it is better for you to display values of other fields, which would make more sense. For this case, you might prefer to display customer names instead of ID numbers. When the report users select a customer name from the list, its ID number is passed to the query as the parameter value so that the search criteria can be fulfilled.
- For Bind with Cascading Columns:
- From the Data Source drop-down list, select the required business view in the current data source from which to get data for the parameter. All the group and detail objects in the specified business view will be available for retrieving values for the parameter.
- Click
to add a parameter row.
- Click in the Bind Column cell and select a field from the drop-down list.
- If you want the values of another field to be displayed for the report users to choose from, click in the Display Column cell and select that field from the drop-down list.
- Click in the Parameter cell to create the parameter. A name for the parameter will then be automatically added by JReport.
- Repeat steps b to e to create more parameters. Make sure that the selected Bind Column fields are of cascading relationship one level by one level down. In this way, a group of cascading parameters are created.
To adjust the order of the parameters, click
or
; to remove any unwanted parameter from the cascading group, select it and then click
.
- In the Options box, set options for the parameter according to your requirements.
- When done, click OK to create the parameter. The parameter is added to the Local Parameters node in the Parameters list.
To further edit the parameter, right-click it in the list and select Edit from the shortcut menu. Then in the Edit Parameter dialog, edit the parameter as required.
To remove the parameter, right-click it in the list and click Delete on the shortcut menu.
- Finish defining the filter condition using the parameter.
- Click OK to apply the settings. The parameter is then listed in the Parameters panel and you can specify the parameter value in the panel to dynamically set the filter condition.
Previous Page Next Page