Reports in MSD 365

To create SSRS report for MSD 365, we need SQL Server Data Tool, its part of Visual studio itself. To create report follow the below steps ..

Reports in MSD 365

  1. Open SQL Server Data Tool (if you don’t have then you can install it from download and install), my recommendation for SSDT is install older version, because it will have Microsoft Dynamics 365 Report Authoring Extension compatibility.
  2. Click on new project
    1. Templates
    2. Select ‘Business intelligence’
    3. Reporting Services
    4. Report Server Project
  3. Now create SQL Stored Procedure, Fetch XML from MSD or off course you can design that from report wizard as well while creating rdl
  4. If you are creating Fetch XML query then Microsoft Dynamics 365 Report Authoring Extension is required to author Fetch-based reports used with Microsoft Dynamics 365 by using SQL Server Data Tools. Click here to download and install.
  5. To create new RDL report in the project,
    1. Right click on Report folder and click on add new item
    2. From here you can choose Report Wizard or Report
    3. For now, lets select Report, it will add a blank report
    4. Now, add Data-source to for the report
      1. On left side window, in Report Data (if this one is not visible the add it from Tools)
      2. Right click on ‘Data Source’ folder and add new Data Source
      3. Just follow the wizard, name the DS, Connection string (here don’t use shared data source, else it will give issue when we put in 365, at least I faced it.. 😀 ), then provide the credentials and click OK button
    5. Now, add Dataset
      1. Right click on Dataset folder and click add new Dataset
      2. now follow this wizard, ref below screen shot for this. Here you will have option to provide your Query, you can use fetch XML, SQL Query or Stored Procedure. Let use Stored Procedure for the tutorial.
      3. Once Query is provided, it will show you all the Fields in its tab and all the Parameter required for the Stored Procedure in that tab.
      4. Once done Click Ok ..


Report design

  1. Now, design your report
    1. If you parameter is a date then automatically it will show you calendar control on the report
    2. if the parameter is lookup reference then you can display it as dropdown
      1. Create a one dataset for this, just pull the Name and id of the reference
      2. double click on the parameter field on report, it will open ‘Report Parameter Properties’ window
        1. In general tab, you can set basic things
        2. in ‘Available Values’ tab, you can set below properties
          1. Get values from a query
          2. Select Dataset
          3. Select Value field
          4. Select Label field
          5. ref below screenshot
  1. From the Toolbox, drag you any component based on requirement
  2. and so on ..
  3. Now, everything is done, now just import it in the MSD environment
  4. Go to Report area or Solution area and import the report
  5. specify where you want to see this report
  6. and to deploy from one environment to another just follow the standard solution deployment process of deployment for MSD and if you are using stored procedures then you have create script and execute on target DB.

Sub-reports in MSD 365

For complex reports, we can use sub-report, sub report is nothing but a another report. you can load it as just not sub part of main report or can be added in table format to repeat along with some other data by passing dynamic parameter.

  1. to add sub report, just add sub-report area from toolbox
    1. you can add just small part of main report
    2. and configure the parameter
    3. Or you can add it in table
      1. To pass dynamic parameter to sub-report, just right click on it and configure the parameter from available values of the main table from main report.
      2. Now, this part will repeat based on that table data
  2. That’s it for sub-report.

You can explore more on same topic here.

Pre-Filter in reports

We can pass current records GUID to the report as well with a small trick. Pre-filtering allows filtering of the report data using the Advance Find functionality and enables users to create context-sensitive reports and return more relevant data.

Pre-filtering passes the set of selected record or a specific record (such as Quote) for which the report is being run in such a way that the report is executed and the data is pulled from the context of the current (or selected) record. Here enableprefiltering=”1″ prefilterparametername=”CRM_FilteredIncident” will do the trick…. Here is the sample query to pass a single parameter ….

<fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="false">
  <entity name="incident" enableprefiltering="1" prefilterparametername="CRM_FilteredIncident">
    <attribute name="ticketnumber" />
    <attribute name="prioritycode" />
    <attribute name="title" />
    <attribute name="customerid" />
    <attribute name="ownerid" />
    <attribute name="statuscode" />
    <attribute name="createdon" />
    <attribute name="caseorigincode" />    
    <order attribute="title" descending="false" />
    <filter type="and">
      <condition attribute="statecode" operator="eq" value="0" />
      <!-- <condition attribute="incidentid" operator="eq" uitype="incident" value="@CaseId" /> -->
    </filter>
  </entity>
</fetch>

In a same manner, Pre-filtering can also be applied to related entities.

In the below screenshot, we are retrieving Opportunity and have applied pre-filtering for both Opportunity and Account. Though I never tried it… but here is the ref for it ..

Pre-filter for fetch based report

Common issues you might face during the development

  1. To avoid error while import, like ‘unable to upgrade the file’,
    1. Solution: you have to change the project property, right click on project property and change the Target Server Version field, select SQL Server 2008 R2, 2012 or 2014 and click Apply then rebuild the project.
  2. Don’t use shared data source, else you will land up in exception while running the report, atleast it happened with me. 😀
  3. While importing the RDL file into MSD, please select rdl file from bin folder not the other one else it will throw a exception.
  4. If you want to print the report or export it in PDF or Word then you need to take care that report width should not go beyond A4 size paper (or you required paper size), other wise, exported or printed pages will move remaining part to the next page or will add blank pages or both of them. TO fix this issue you need to adjust your report width.
  5. [rsParameterReference] The Value expression for the query parameter ‘@siteId’ refers to a non-existing report parameter ‘siteId’. Letters in the names of parameters must use the correct case.
    1. Reason: it happens when you rename or adding or removing the parameter from the SQL query
    2. Solution: Right click the dataset and open properties then go to Parameters. You’ll see parameter name and value. While it may look correct, click on the expression button next to the parameter value and look at the expression within. If it’s in the incorrect case e.g. =Parameters!siteId.Value you need to correct it here. ref below screen shot …

That’s it for now .. !!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s