Simple Custom Parameters Report
For this example, we will build a report which displays a set of results based on a Sitecore Query and custom parameters.
The report will display all items under a path selected by the user in the content tree and only return items of a template selected by the user.
Let’s build it
Step 1: Create a new filter called “Items of Type” and configure as per the image.
Step 2: Create a Parameter item called “TemplateID” and configure as per the image.
Note that the root id refers to the root templates folder you wish the user to be able to filter from.
Step 3: Create a report item called “Items by Template” and configure as per the image.
Step 4: Run the report from ASR. Here you can see we have run the report to return all articles within the categories node of the content tree.
Simple Sitecore Query based Report
For this example, we will build a report which displays a set of results based on a Sitecore Query.
The report will display all items under a fixed path in the content tree and only return items of predefined specific templates. The report query is fixed and doesn’t require any user input via report parameters.
Let’s build it
Step 1: Create a scanner called “Simple Sitecore Query” and add a query as per the image. The query below gets all items under the categories node where the template is one of the three listed types of templates.
Step 2: Create a new report called “Simple Sitecore Query Report” and configure as per the image.
Step 3: Run the report from ASR. Here you can see we have run the report to return all items of the specific templates within the categories node of the content tree.
Firstly download the install package and the source code. https://marketplace.sitecore.net/en/Modules/A/Advanced_System_Reporter.aspx
ASR reports are easy to configure and most of the time require no custom code to be written.
When a custom report requires coding the easiest way is to follow the examples found in the source code. There are also some filters; scanners etc. which are not in use by the default reports that are very handy and you would not know about them unless you have a browse through the ASR projects.
Report: The report item pulls together the configuration elements required for the ASR report: Scanners, Filters, Viewers, and Commands.
Viewer: The viewer item defines the report view, the columns to display etc.
Scanner: The scanner item defines the search query to populate the viewer.
Parameters: The parameter item defines a parameter input control to be used within a report. It defines what type of control and default values to display or select from depending on control type.
Parameter Type: The parameter type item defines a control type to be used by a parameter for a report. The default Parameter types, for example, are Date picker, Dropdown, Text etc.
Filters: The filter item adds filters to the scanner to provide filtered results for the report. Filters have an attribute field which maps a parameter item to a property within your filter class.
Command: The command item adds commands to the report ribbon. The commands can be used to execute functionality on items in the report.
All Items Scanner
The All items scanner is a great utility scanner. It references the QueryScanner which takes a Sitecore query from the attributes field. This allows you to create a report to output the results of any Sitecore query.