Defining report parameters
Reports and their data can be filtered using parameters.
To create parameters for reports:
Open the Reporting application.
Select the report in the tree.
Switch to the Parameters tab.
Click New field.
Define the properties of the parameter (using the field editor).
Click Save.
Switch to the General tab.
Add the parameter to the queries of the report objects (table, graph or value).
- All parameters that you define can be used in the query using the @<parametername> expression (e.g., DocumentCreatedByUserID = @UserIDParameter).
For an example of using parameters in reports, see the Defining report parameters section of Example - simple report.
Context parameters
In your queries, you can use parameters that provide information about the current context when the report is viewed, such as current user, current site, etc.
- @CMSContextCurrentUserID
- @CMSContextCurrentUserName
- @CMSContextCurrentUserDisplayName
- @CMSContextCurrentSiteID
- @CMSContextCurrentSiteName
- @CMSContextCurrentSiteDisplayName
- @CMSContextCurrentDomain
- @CMSContextCurrentTime
- @CMSContextCurrentURL
- @CMSContextCurrentNodeID
- @CMSContextCurrentCulture
- @CMSContextCurrentDocumentID
- @CMSContextCurrentAliasPath
- @CMSContextCurrentDocumentName
- @CMSContextCurrentDocumentNamePath
For example, if you want to display a list of all expired documents of the current website, you can use a query like this:
SELECT DocumentNamePath AS [Document path]
FROM View_CMS_Tree_Joined
WHERE DocumentPublishTo < @CMSContextCurrentTime AND NodeSiteID = @CMSContextCurrentSiteID
Displaying parameter values in the report using macros
If you need to display the parameter values in the report, you can place the following macro expression in the report text: {%parametername%}
For example:
List of pages expired on or before {%CMSContextCurrentTime%}
displays:
List of pages expired on or before 2/12/2013 12:06:49 PM
You can use this syntax for both custom report parameters and context parameters.