Development, Reports

MS CRM 2011: General approaches to generation of reports

Following article describes general steps to use web services of Reporting Services.

Preparation of report
The easiest way is to develop and test report for CRM and then make it available for external usage (or use in-build report of CRM). In following samples I will use standard Quote report.
To publish report for external use Open CRM, navigate to report, choose Report and click Edit:
Once report is opened click Actions – ‘Publish report for External Use’:


To recheck that reports were published open your reports url – http://[Reporting Server]:[Port]/Reports/Pages/Folder.aspx (in my case it is http://crm/Reports/Pages/Folder.aspx):
Click on folder called YourCRMOrganization_MSCRM (in my case it is Contoso_MSCRM):
In case your report has subreport report will be published for external use as well but main report would be broken. How to fix it you can check here.
In case your report has to receive some parameters you should get names of those parameters. To do it click on dropdown near the name of the report and choose Manage, then select Parameters:



Usage of Reporting Services web services
For development of extension for CRM I use developer toolkit. So I created deployment package and Workflow Project. Next step is adding of reference to Reporting Services web service. Proceed following steps to add reference of Reporting Services service to your project:





 Once you’ve done it you should get something similar in your project explorer:
Development – helper class that allows generation of report
Add class to your project and put following code into it:


Development – usage of helper class

As a sample that shows how to use this helper class I took following scenario – CRM user prepared Quote for customer and decided to send it using email. Using out of box features it would require a lot of steps – open prepared quote, run report, save it somewhere, create new email, attach saved file to email and send. Provided custom workflow activity makes this process easier. As input parameter it receives reference to an email to which file has to be attached:


Build project and register it in CRM using Developer Toolking or Plugin Registration Tool.

In provided sample I hardcoded credentials and Url of webservice. You can use it as it is but from point of flexibility and security it is better to store this settings somewhere – it could be config file on server, registry keys or some configuration entity in CRM.

Design of workflow
Following screenshots show how to create workflow that uses created custom workflow activity:









Following screenshots demonstrate usage of workflow action:






  1. Thanks for sharing. One question, what "account" actually runs your report (in the SSRS shared data source)? We tried to enable kerberos delegation to solve a double-hop (separate CRM database), but ended up using a "CRM System" account.

  2. Hello,
    In my test system I have SQL and RS installed on the same server so I didn't have any chance to test separated scenario. I believe that usage of special AD Account is fast and effective workaround.

  3. Hello Andrii,
    I have followed your recommendations to attach a report to an email. The report attached ok, but when I open it (I render the report as PDF) I can only see the first title label. I have a Tabflix defined in my report. Could it be a problem to render it?

    Thanks for your post. It's a proposal very interesting and useful.

  4. I answered myself. The problem was the credentials. I had used the CredentialCache.DefaultCredentials. When I change this value to one AD crm user I can see the report results.

  5. Hi Andrii,
    Getting an error for the last parameter although I ended up hardcoding the value:
    Exception: Unhandled Exception: System.Exception: Error generating report – rsReportParameterProcessingError400Error during processing of ‘IsKroger’ report parameter.

    ReportGenerator reportGenerator = new ReportGenerator(reportUrl, CredentialCache.DefaultCredentials);
    ParameterValue[] parameters = new ParameterValue[3];
    parameters[0] = new ParameterValue();
    parameters[0].Name = “SlotId”;
    parameters[0].Value = “25408F61-24B7-E611-8112-005056A850EB”;

    parameters[1] = new ParameterValue();
    parameters[1].Name = “RetailMarketId”;
    parameters[1].Value = @”Select Superf_RetailMarket As RetailMarketId
    From FilteredSuperf_Slot (Nolock) As S
    Where Superf_SlotId = ‘2458F61-24B7-E611-8112-005056A850EB'”;

    parameters[2] = new ParameterValue();
    parameters[2].Name = “IsKroger”;
    parameters[2].Value = “0”;

    1. Hello,
      Based on the name I can assume that IsKroger parameter is boolean. Try to assign false to value of parameter like
      parameters[2].Value = false;

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.