Report Parameters
Parameters
Watch the videoAs we covered in the overview, the Data Panel is pretty simple at first glance. When creating a new report, there is an empty list of Data Sources as well as pre-made Parameters. Parameters are Ignition Expressions. These parameters resolve at report execution time and provide a convenient way to dynamically specify content for your report. These expressions are expected to resolve to specific types.
The Parameter Types available in the ComboBox will be familiar to anyone who has used Expressions, and include:
- Date
- String
- Long
- Double
- Boolean
- Dataset
- Binary Data
Parameter values can be shown directly on your report, or be referenced by data sources and other parameters. Parameters are given a default value when first created, but this value can be overridden once the report runs.
How Parameters Are Used​
Parameters allow an Ignition user to specify dynamic data to be used in reports at runtime. For example, a manufacturer may want to generate reports for the active production lines every Monday morning, but you don't know ahead of time which production lines will be running. We can create a parameter called activeProductionLines and use an expression or tag value to determine which lines were active, and use the parameter in a SQL Query datasource to only include data from active lines.
By default, parameters are supplied a value in the Report Data panel (called default parameters) that will be automatically be supplied to the Report Viewer component. These default values are used during report execution unless specific values are supplied for the parameters. Without these supplied values, and no other parameters are defined, the Report Viewer and Preview Panel will notify the user that a parameter is undefined. Parameters can be declared values from the Report Viewer component, or in the Report Scheduling panel. The Report Viewer can use parameters to bind to data through Ignition Bindings. Both Scheduled Report and Report Viewer parameters take precedence over default parameters, allowing any default parameter to be easily overridden while also providing a baseline value.
Since default values for parameters are evaluated in the Gateway, the expressions have a Gateway scope.
Default Starting Parameters​
When you first create a report, you start with two parameters: StartDate and EndDate. EndDate will have a default value of 'now()', while StartDate will have a default value of 'dateArithmetic(now(), -8, "hr")'. For example, the default value of the StartDate can be modified from 8 hours to 10 days by editing the Default Value expression.
dateArithmetic(now(), -8, "hr")
dateArithmetic(now(), -10, "days")
You can also delete both StartDate and EndDate parameters if you do not need date parameters in your report.
Creating New Parameters​
New parameters may be added by clicking the Add icon. Use the Delete icon if a created parameter needs to be deleted.
Once created, a default value should be given to the parameter. In addition to expressions, you can also have your default value reference a tag using the Tag icon on the right of the expression area.
You can also use a literal value. Normal Expression languages syntax applies, so dates and strings must be wrapped in quotation marks, but numerical values can be written without quotes.
Finally, you can reference other parameters. In the example below, BoolParameter is referencing the value of IntegerParameter.
if ({IntegerParameter} = 1000, 1, 0)
It is important to note that when referencing other parameters, you must type the name of the parameter exactly within a set of curly braces { }, including capitalization. Also, you can only reference parameters that are above the current parameter. Thus, while BoolParameter can reference the IntegerParameter, the IntegerParameter may not reference BoolParameter. Parameters can be reordered using the Move Up and Move Down icons.