Category Archives: Dynamics CRM

Hosting an SSRS Report in a Dynamics CRM 365 Form

Introduction

So, as we all know, reports can be designed using Visual Studio or Report Builder and uploaded to the Reports section in CRM.  But, what if you want to display the report directly in a form?   This is what a client wanted to do as it would enable their users to view non CRM data in a CRM form.  In the past they had issues with browser security and had not gotten very far.

 

Testing the Report

To test this I utilized an Azure VM which had SQL Server 2014 including SSRS (SQL Server Reporting Service) installed onto it.  A SQL Table and a sample report were created, which looked as below:

2017-10-23_11h00_17

Next, a new CRM form was created and an IFRAME added to it with the URL (http://crm2015dev/Reports/Pages/Report.aspx?ItemPath=%2fTestSSRSReport%2fTestSSRSReport) of the above report.  The number of the rows for the IFRAME were set to 12, from the default of 6.

On opening of the CRM form 2 security prompts were displayed, and required accepting before the report would be shown.  These are the 2 prompts:
2017-10-20_12h12_06

2017-10-23_14h51_27

 

Removing the IE Security Prompts

A bit of searching online and in forums revealed the 2 Internet Explorer settings that needed to be changed to remove the prompts.  Both settings are in the same dialog.  To get to the dialog open the IE internet options dialog, then the Security Tab.
Select ‘Local intranet’, then click the button ‘Custom level…’

2017-10-23_11h19_20

Locate the option ‘Display mixed content’ and change it to ‘Enable’2017-10-23_11h20_54

Locate the option ‘Websites in less privileged web contents zone can navigate into this zone’ and change it to ‘Enable’

2017-10-23_11h23_47

After restarting IE the the CRM form now displays the SSRS report with no security prompts:

2017-10-23_11h28_21

 

Conclusion

Once you know the settings to change for IE it’s pretty straightforward to remove the security prompts.  I should say that I’m no expert in IE and I’m not sure of the security implications of making these changes so if you’re in a corporate environment check these settings with your Desktop Team.

NOTE: These are the version numbers of the applications:
CRM: Microsoft Dynamics 365 Version 1612 (8.2.2.111) (DB 8.2.2.111) online
SSRS: SQL Server 2014 SP1 (Version 12.0.4100.1)
Internet Explorer (IE): Version 11.0.9600.18817

 

Photo by William Iven

Using Power BI with Dynamics CRM 365

Background

Recently I was asked by a client to look into the possibility of using Power BI Dashboards/Reports and displaying them inside their CRM Online instance.  One of the priorities for the investigation was to ensure that the dashboards/reports could be filtered for the current user.  For my test I want to be able to build a dashboard that shows the CRM activities for the logged in user.

 

Initial Investigation

Power BI licensing looks very reasonable.  No cost to author reports and publish online, and $9.99 (approx £7.50) for the Pro version which gives the ability to be able share reports and schedule data refreshes.  Also, a quite lengthy 60 day trial is available which is plenty of time to see if it’s right for you.  After a bit of reading it seems that Power BI can be set to suck in data from a number of data sources, store it internally, and then build very nice looking charts from the data.  The data can be set to refresh at regular intervals, though the minimal refresh period is 1 hour, and this scheduled data refresh requires a Pro license.

 

Data preparation in CRM

To enable me to test the reports/dashboards I’ll be using the CRM Activity entity.  There are a few dozen records in my test CRM instance, and I am the owner of one of the activity records.

 

Power BI Desktop

Using my MSDN account I created an Azure Virtual Machine running Windows 2012R2 and installed the Power BI Desktop.  It’s free to install and use (the installer is 143MB).PowerBIDesktop

Adding Data to Power BI

Clicking on the Get Data button brings up a dialog with a list of many available data source types.   Entering 365 into the search box filters the list allowing the selection of ‘Dynamics 365 (online)‘.

DataSources

The next dialog prompts for the Web API URL for the CRM instance:

EnterWebAPIDialogThe Web API URL for your instance of CRM can be found by navigating to Settings\Customizations, clicking on Developer Resources, and copying the value out of Service Root URL.  Selecting the value with your mouse and then using Ctrl+C will copy the value.

WebAPIURL

Next is a prompt for my CRM login credentials.  Having entered the credentials a list of entities that are in the CRM instance is displayed.  I selected systemusers and activitypointers – filtering the list using the search box makes it easier to find an entity:

FilterEntityList

Filtering Data by User

The data can be filtered to only show data for the current user by using Row Level Security (RLS).  RLS is basically how you can configure the data to be filtered by criteria which is configured per role.  I will simply be adding a role to filter the systemusers table for the logged in user, and as the activitypointer table is joined to this table, it will be filtered also.
The first step is to make a one-to-many join between the two tables.   This is achieved by clicking on the relationships tab to go to the mapping screen.

RelationShipsTab

From here the two tables are visible, and can be resized to view more of the columns.  To create the link drag the systemsusers ownerid column to the activitypointers _ownerid_value column:

DragColumns

There should now be a line linking the two tables with a 1 on the systemusers side and a star on the activitypointers side.  Double clicking the join allows the properties to be viewed – it should be:

RelationshipDialog

The next step is to add the filter.  Click back to the Home tab and then the Manage Roles button:

HomeTab  ManageRolesButton

This is the filter that should be added:

RLSFilter

Displaying Data

We can now add the data to the main view area.  For our test a simple grid of data will be sufficient.  On the list of Visualizations click the Table icon:

TableIcon

This inserts a table onto the main view area and columns from the far right table can now be dragged onto it.  Formatting the table is done by selecting the table, then the ‘Paint’ icon and changing the values.

PaintIcon

This is how mine looks:

FinishedTable

 

Testing

It’s very important to test what we’ve done as we don’t want users seeing other users data.  Click on the ‘View as Roles’ button:

ViewAsRoles

Then enter the following selections, using your email:

ViewAsRolesEntry

The data in the table should now be filtered to display just your data:

FilteredDataInTable

Publishing

The next step is to Save and Publish the Dashboard to Power BI Online.  This is done by clicking File\Save (mine is called CRMUserActivities) then File\Publish  and then Publish to Power BI.
Next, go to the Power BI application website.  The next step is critical also, as we’re going to configure which users the Filtering applies to.  Expand ‘My Workspace‘ and under DataSets there will be your dataset.  Click on it, then click the ellipsis, and the menu option Security:

DataSetSecurity

Now, all the users should be added to the Row-Level Security.  This can be a bit tedious but I don’t think there is any way around this:

RLSMembers

 

Convert Report to a Dashboard

To convert the report to a dashboard that is viewable on CRM the first action is to open the report and click on ‘Pin Live Page’

PinLivePage

A dialog is displayed and ‘New dashboard‘ can be selected and the name of the dashboard entered:

PinToDashboardDialog

By default Power BI displays Report page numbers which can make the dashboard look a bit untidy.  Removing the page numbers is not very intuitive, and it took me a while to figure out how to remove them.  Firstly click on the new dashboard that has been created under the My Workspaces tab:

OpenDashboard

The next step is a bit tricky.  Move your mouse over the dashboard and an ellipsis should appear to the top right.  Click on this ellipsis:

DashboardEllipsis

This brings up another menu, click on the ‘Pencil’ icon:

DashboardSubMenu

Finally, we are on the correct the window.  Untick ‘Display title and subtitle‘ and then click Apply.

DashboardTileDetails

Note: There is also an option on this dialog to ‘Display last refresh time’.  This is the date/time the Dashboard was refreshed by Power BI – an item you may want to show to yours users.

Add the Dashboard to CRM

We’re nearly there..   To enabled Power BI dashboards in CRM there’s a setting under Settings\Administration and then System Settings.  In the Reporting tab there’s an option to enable Power BI Dashboards – set this to Yes:

CRMSystemSettings

In CRM, go to the Dashboards screen, and click on the arrow to the right of the New button, and select Power BI Dashboard:

CRMPowerBiMenu

And finally you can select your Power BI Dashboard

CRMPowerBiDialog

I also added a pie chart and a total count to my dashboard.
An added bonus is that Power BI Dashboards are interactive, in that you can select records in the table, or items in the charts and the other tables/charts will update accordingly.   For example:

Select records in the table

Dashboard-RecordsSelected

Selected items on the chart

Dashboard-ChartAreaSelected

 

Testing Dashboard if you’re the Creator

On creating my first dashboard using this method it didn’t appear to work and after some time I realised that the creator of the dashboard sees all of the data.  This can be a bit confusing – I’ve read it’s because the creator of the dashboard is the owner of the report and the dataset.
There is a method of testing the Dashboard if you’re the creator/owner.  Go back to the  Power BI application website, open the dataset Security settings:

DataSetSecurity

Then select the RLS item, click on the ellipsis, and click on ‘Test as role’

PowerBITestAsRole

You can now test the Dashboard using your data:

PowerBiViewAsTestRole

What Power BI dashboards should not be user for

Power BI dashboards can be made to use live data vis streaming, but the method described above uses data that is updated on a scheduled basis.  This means that they shouldn’t replace normal CRM dashboards where the data is refreshed live, i.e. outstanding customers to call.

Conclusion

I hope this gave you a good introduction to Power BI and CRM and what they are capable of in terms the creation of meaningful interactive Dashboards.

 

Photo by Carlos Muza