Skip to main content
A newer version of this page is available. .

Parameters

  • 3 minutes to read

This document describes the main concepts for using parameters in Snap, and provides examples of their use in various tasks.

The document consists of the following sections.

Create Parameters

You can manage the report parameters available for a Snap document using the Parameters dialog.

To invoke the Parameters dialog, right-click the Parameters node (or any of its sub-nodes) in the Data Explorer and select EditParameters in the invoked drop-down menu.

snap-data-explorer-parameters-edit

The Parameters dialog allows you to add and remove parameters using corresponding buttons. Alternatively, you can add or remove a parameter by right-clicking the parameter in the Data Explorer and selecting the required action in the invoked drop-down menu.

Select the newly added parameter and specify its properties in the properties grid. Be sure to specify the proper parameter type based on the parameter’s intended use.

snap-query-designer-parameters-dialog

Note

Update all fields in the document after the parameter value has been changed.

Pass Parameter Values

After a parameter is created, it can be used in different ways during report generation. Below is a list of tasks that can be solved using parameters.

  • Data Binding

    To display a parameter’s value in a report, drag the parameter from the Field List and drop it onto the Design Surface.

    snap-parameter-drag-and-drop

  • Filtering

    You can use a report parameter as part of a filtering expression to filter the Snap document data at either the report level or the data source level.

    To filter the Snap document data at the data source level, do the following.

    1. Invoke the Query Builder for the data source that you wish to filter.
    2. In the Query Builder window, click the Filter button to invoke the Filter Editor.

      snap-query-designer-filter

    3. In the Filter Editor, construct an expression where the parameter’s value is used as a filtering criterion. To access the parameter, click the icon on the right until it turns into a question mark.

      snap-query-designer-filter-editor-criteria-parameter

      Click OK to exit the dialog.

      The SQL query generated by the query designer will be updated to reflect the specified filtering.

      snap-query-designer-sql-editor-parameter

      Important

      Manual SQL editing is not allowed by default. Enabling custom SQL queries may lead to inadvertent or unauthorized modifications to your data/database structure. Before you decide to allow manual SQL editing, we recommend you to follow best practices and implement the appropriate end-user read/write permissions at the database level.

      If for some reason you have to enable custom SQL editing, set the SnapControl.Options.DataSourceWizardOptions.SqlWizardSettings.EnableCustomSql option to true.

      Note that only SELECT statements are allowed in the text. To override this restriction, handle the SnapControl.ValidateCustomSql event.

    In a similar way, you can use the Filter Editor to filter the Snap document data at the report level. In this case, to invoke the Filter Editor, click the Filter button that resides on the List tab of the contextual Data Tools toolbar category.

    snap-filter-command

  • Calculated Fields

    In addition to standard data fields, parameters can be used in expressions for calculated fields. The only difference is that the data field is inserted into the expression’s text using its name in [square brackets], while a parameter is inserted using the “Parameters.“ prefix before its name.

    snap-parameter-calculated-field

See Also