Managing reports and their categories

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

The following sample code shows how you can create a new report category and add it to the system:

 

[C#]

 

using CMS.Reporting;

 

...

         

        // Create new report category object 

        ReportCategoryInfo rci = new ReportCategoryInfo();

 

        // Set properties

        rci.CategoryDisplayName = "Test category";

        rci.CategoryCodeName = "TestCategory";

 

        // Save to database

        ReportCategoryInfoProvider.SetReportCategoryInfo(rci);

 

The following sample code shows how you can create a new report under an existing report category and add it to the system:

 

[C#]

 

using CMS.Reporting;

 

...

 

        // Get parent category for the new report

        ReportCategoryInfo parent = ReportCategoryInfoProvider.GetReportCategoryInfo("TestCategory");

 

        // If parent exists

        if (parent != null)

        {

            // Create new report object 

            ReportInfo ri = new ReportInfo();

 

            // Set properties

            ri.ReportDisplayName = "Test report";

            ri.ReportName = "TestReport";

            ri.ReportCategoryID = parent.CategoryID;

            ri.ReportAccess = ReportAccessEnum.All;

            ri.ReportLayout = "";

            ri.ReportParameters = "";

 

            // Save to database

            ReportInfoProvider.SetReportInfo(ri);

        }

 

The following sample code shows how you can delete an existing report:

 

[C#]

 

using CMS.Reporting;

 

...

 

        // Get report object by report code name

        ReportInfo ri = ReportInfoProvider.GetReportInfo("TestReport");

 

        // If report exists

        if (ri != null)

        {

            ReportInfoProvider.DeleteReportInfo(ri);

        }

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_managing_reports_and_their_categories.htm