Debugging script of RPX (Section) report

Posted by: scosovic on 15 March 2018, 12:05 am EST

    • Post Options:
    • Link

    Posted 15 March 2018, 12:05 am EST

    Hi,

    I’d like to know whether there is a way I can debug the script code of a RPX (Section) report running in HTML5 Viewer.

    Basically I’d like to put a break point in the code, break the execution of the script and step through it to debug it.

    I’d appreciate any help on this.

    Thanks…

  • Posted 15 March 2018, 8:16 pm EST

    Hi,

    Since the HTML5 Viewer is a client side viewer, all the report processing is done internally through the ActiveReports.ReportService.asmx service. For your requirement to debug the script, you would need to use a custom ReportService which inherits from the ActiveReports ReportService and create an object of SectionReport with its EnableScriptDebugging property set to true.

    public class CustomReportService : GrapeCity.ActiveReports.Web.ReportService
        {
            [WebMethod]
            protected override object OnCreateReportHandler(string reportPath)
            {
                switch (reportPath)
                {
                    case "Reports/Invoice.rpx":
    
                        SectionReport rpt = new SectionReport();
                        XmlTextReader xtr = new XmlTextReader(Server.MapPath(reportPath));
                        rpt.LoadLayout(xtr);
                        rpt.EnableScriptDebugging = true;
                        rpt.Run();
    
                        return rpt;
    
                    default:
                        return base.OnCreateReportHandler(reportPath);
                }
            }
        }
    

    To be able to debug through the script, add the following line of code in the ReportStart event in the script section:

    public void ActiveReport_ReportStart()
    {	
    	System.Diagnostics.Debugger.Launch();
    }
    

    Now, put a breakpoint on the rpt.Run() line and run the application. When the breakpoint on rpt.Run() is hit, press F11 to step into the report script to debug.

    You would also need to change the reportservice url in the HTML5 Viewer:

    viewer = GrapeCity.ActiveReports.Viewer({
                    element: '#viewerContainer',
                    reportService: {                   
                        url: 'CustomReportService.asmx'
                    },
    

    Hope it helps

    -Abdias

  • Posted 15 March 2018, 11:35 pm EST

    Abdias,

    Thank you very much. That did it for me.

  • Posted 20 March 2018, 11:29 pm EST

    Hi Abdias,

    After your first reply I was able to set it all up and F11 worked for me. I was able to step into the script of my report. After trying it today again, for some reason it does not work for me any more.

    The break point is still hit in my custom report service class (rpt.Run()), but when I press F11 it just takes a second and steps right over it. It does not go inside the report script.

    I’ve tried cleaning and rebuilding the project but it still does not work. Any idea what would be causing this to happen and why I cannot debug it any more?

    Thanks…

  • Posted 26 March 2018, 12:05 am EST

    Hi,

    Sorry for the delay in my reply. Could you please check the script if there is any code that could be causing an error or an expression that isn’t getting evaluated correctly. Also, please try deleting the bin and obj folders and then re-run the application.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels