Power BI recently started supported embedding Power BI visuals securely out-of-the-box. That means we can now show Power BI reports inside Dynamics 365, without having to deal with authentication.
And with minimal use of code, we can filter the visual to the record that it is being displayed on. Like this.
I have previously written about embedding Power BI visuals on forms in Dynamics 365. Until recently that required code to handle the authentication, or use of Trond’s “Power BI Viewer” tool to handle it for you. That’s all described in this blog post. https://crmchartguy.com/2018/02/11/contextual-power-bi-reports-on-dynamics-365-forms/
The new embed feature in Power BI handles the authentication for you and is easy to use. On the Power BI website, navigate to the report you want to embed in Dynamics 365, click on File, and select Embed.
This will give you a link referring to the specific report.
Try it out and paste the link in a browser and you will see the whole report without the Power BI menus etc.
In our scenario though, we want to filter the report to a given customer and then show it on the Account form.
To filter the report, we can use the standard URL filter parameters. I’ve discussed those in more detail here. https://crmchartguy.com/2017/03/30/record-specific-power-bi-reports-in-dynamics-365-only-one-click-away/
In short, we need to add ?filter=Table/Column eq ‘GUID’ to the end of the link we got from the Secure Embed feature.
An example of filtering to the account record would be:
?filter=Account/accountid eq ‘329874328fsh9843298743298’
This example assumes the table is called “Account” and the field with the GUID is “accountid”.
All URL filter parameters, in case you need more advanced filters are available here. https://docs.microsoft.com/en-us/power-bi/service-url-filters
Now I just need a web resource that takes the embed link from Power BI and tags on the filter parameters including the GUID of the current record.
As I am no developer, I found this old web resource which did something very similar. I am sure it can be optimized by a real developer. (In case you are curios, the web resource is from the old Customer Insights solution. I believe Microsoft has taken the material down, so I can’t provide a link to the original.)
Disclaimer: Code sample provided for fun and testing purposes only.
In Dynamics 365, create a new web resource of type HTML in the solution editor.
Copy the above web resource code into it with two important modifications.
- Insert your URL from Power BI
- Modify width and height to match the intended area on the form
Go to the Account form to add the web resource we just created. Make sure you give the component enough space on the form.
Once added, we can publish and see the Power BI report embedded, filtered to the current account, and authenticated directly via Power BI.
When using Trond’s Power BI Viewer, we had some options to hide the filter pane and navigation tabs. Those options do not seem to be working here (based on my limited testing).
Note that we in the October 2018 release notes were promised an out of the box feature that would handle this process automatically. Link here. https://docs.microsoft.com/en-us/business-applications-release-notes/october18/powerapps/power-bi-embedding-available-in-common-data-service-entity-forms
It seems that the Secure Embed feature has been a prerequisite to make this work, but it is of course still anyone’s guess when the built-in feature in Dynamics 365 will be released.
This is one of the features from the October 2018 release that I am the most excited about. And yes, I do realize I am writing this in February 2019.
For now, I do consider the above a nice option for demos and proof of concepts. If used in a Production environment, I would consider this a temporary measure until the baked in feature is available.
As with any Power BI report, the data does not adhere to the Dynamics 365 security model, so be attentive to what is being shared. There is also an assumption that the users in Dynamics 365 have the Power BI report shared with them and that they have a Power BI pro license.
Here’s the link to the Power BI blog introducing the feature https://powerbi.microsoft.com/en-us/blog/easily-embed-secure-power-bi-reports-in-your-internal-portals-or-websites/
Enjoy. As always, please sign up for my newsletter or follow me on Twitter Follow @CRMChartGuy