This topic describes how to add custom reports in Episerver Commerce. The built in reports are done with Microsoft SQL Server Reporting Services using local reports. You can create local reports and reports stored on a reporting services server. If you use the remote option, you can take advantage of the subscription services to distribute the reports automatically at a desired frequency.
Classes in this topic are available in the following namespaces:
Adding custom reports
Follow the steps below to create a custom report.
- Create a new Web Application.
- Remove the default.aspx page and web.config file. You can leave them if you want to test the project outside of Commerce Manager.
- Copy the Apps/Reporting/Config folder and its content to the new project.
- Copy Apps/Reporting/Reports into the new project, if you are using the SQL Reporting services.
- Edit the Config/Naviation/LeftMenu.xml file to include a new report. The following example adds two parent links New Local Reports and New Server Reports with a report for each one.
Example: adding report linksXML
<Link id="NewLocalReports" text="New Local Reports" iconUrl="~/Apps/Reporting/images/report-group.png" iconCss="treeIcon">
<Link id="ApplicationLog" text="Application Log" iconUrl="~/Apps/Reporting/images/report.png" iconCss="treeIcon"
<Link id="NewRemoteReports" text="New Server Reports" iconUrl="~/Apps/Reporting/images/report-group.png" iconCss="treeIcon">
<Link id="ServerReport" text="New Report on Server" iconUrl="~/Apps/Reporting/images/report.png" iconCss="treeIcon"
Edit the elements under the section Navigation/Commands/Add element. The following example shows two commands for the two new report links added. The second command passes a querystring to the ChangeView method, which lets the view have parameters if needed.
Example: adding report links to navigationXML
<ClientScript>CSManagementClient.ChangeView('Reporting', 'viewNewServerReport', 'Report=testreport')</ClientScript>
Add a new view under config folder:
- Add a new view by copying an existing one and renaming the file name to the new viewname.xml.
- Make sure the View ID is the same as the unique view name set in command that changes the view.
- The name attribute is used as the header title in Commerce Manager when the report is being viewed.
- For the controlUrl, specify the name and path of a new .ascx file to be created. It should be in this form: Reporting/Your ascx name.
The following example shows two new views to go with the two new links created earlier.
Example: adding report views to a view fileXML
<View id="viewApplicationLog" name="Application Log" controlUrl="Reporting/LocalApplicationLog.ascx"></View>
<View id="viewNewServerReport" name="New Server Report" controlUrl="Reporting/RemoteReportViewer.ascx"></View>
- Create a new ascx control using the name from the controlUrl in the previous step. Place it in the root of the new project. This ascx defines the appearance and functionality of the report when displayed.