Resolve Report Timeouts in Dynamics CRM Custom Workflow Activity

Posted By

One of our clients had a requirement for a Custom Workflow Activity that would allow them to attach Microsoft Dynamics CRM reports to emails as PDFs. We have adapted the software so that its use is viable in more than one report, simply by adding various input parameters to the Custom Workflow Activity.

While recently doing work on the Custom Workflow Activity to generate new reports as PDFs, I had some trouble. Reports would load in my local development environment, but kept timing out in the client’s environment.

Some investigation on the client’s SQL Server Reporting Services (SSRS) server showed that while the report loaded quickly in CRM, the externally published report was very slow to load the server.

While researching the problem, I found that the default timeout value for the Report Execution Service is 100 seconds, which was not long enough for this particular report.

To resolve the problem and allow adjustments for future reports, as well as longer load times in other environments, a ReportServiceTimeout parameter was added to the custom workflow activities input parameters (Figure 1).

Figure 1


The input parameter is a whole number and the code handles the minimum and maximum value restrictions that were entered. If the value is 1 or lower, it ignores the input parameter and allows the default timeout value to be used. If the number entered is greater than 6, then the timeout value is set to 600 seconds. If the number is 2 – 6, then it uses a formula to get the timeout value.

Here is the code sample:

ReportService.ReportExecutionService rs = new ReportExecutionService();

// other rs properties set here

//if the timeout input value was null don’t set the rs.Timeout value, it will default

//to 100000 milliseconds

if (reportServiceTimeout.Get(_executionContext) != null)


int rsTimeout = reportServiceTimeout.Get(_executionContext);

//likewise, if the input value was 1 or less, let it default

//to 100000 milliseconds

if (rsTimeout > 1)

{ rs.Timeout = rsTimeout <= 6 ? 100000 * rsTimeout : 600000; }


// Load the report

execInfo = rs.LoadReport(reportPath, historyID);

Adding this code allowed us to extend the time for larger reports, and resolved our long load time errors while generating PDFs.


BDO eBook - The Cloud Changes the Game

There are times in the course of your business when you have the opportunity to dramatically accelerate growth and improve day-to-day efficiencies. Recognizing