Dynamics Ninja Logo

Blog.

Power BI Embedder for XrmToolBox

Cover Image for Power BI Embedder for XrmToolBox
·
4 min read

Introduction

I can finally announce that my first XrmToolbox tool is publicly available. It's called Power BI Embedder and it allows you to embed Power BI reports into the forms on your Model-Driven apps.

GitHub Repository

The idea about the tool popped up in Brussels during the session "XML Hacks - Customisation Tips for Dynamics 365 Solutions" by Marc Gerner where he showed an example of how you can embed Power BI report into the form via manipulating the form XML. I thought it's quite repulsive for most users out there and because of that it's maybe not used at all.

How to do it via XML is actually quite good documented on the official Microsoft docs page, but still, let's see how can you do it with the Power BI Embedder tool for XrmToolBox.

Download

You can get the tool like any other tool via the Tool Library inside the XrmToolBox by searching for Power BI Embedder. Once it's downloaded you can find it in the Tools tab.

The UI

The UI is quite simple and allows you to easily populate all the required fields to achieve the final goal.

The first section called Target is the part where you choose the location where your Power BI report will be embedded. You are guided with 4 dropdowns to the final location which will be the form.

The next section is the Formatting one that allows you to choose the Section Name that will actually overwrite the current section label. and the height of the section that handled by the Rowspan attribute.

The third step is where the magic starts to happen and it's the most complex one because you need to search up all the required data needed.

Power BI Config section

The only prerequisite is that you have your report published online. After you did this go open https://app.powerbi.com to find the right parameters.

The group ID is the first thing you need to find here and it's quite easy if you want to use the report that is located in the place called My Workplace. In that case, the Group ID parameter will always be equal to 00000000-0000-0000-0000-000000000000.

If you are not that lucky you will need to dig a bit more for the Group ID value. It's not hidden that deep.

Go to the workplace that contains your Power BI report, open Reports tab and open up the report you want to embed. Check out the URL from the browser and it should like something like the one below.

https://app.powerbi.com/groups/420ab21a-031a-48ce-97ec-061af35ed1dd/reports/8699df09-bf84-4d0e-bf06-37d5df426f49

GUID after the groups part is the Group ID that you are looking for, 420ab21a-031a-48ce-97ec-061af35ed1dd in this example.

The next one up is Report ID and it's quite easy when you already have the report URL.

Report ID is the GUID that is positioned after the reports part in the URL.

https://app.powerbi.com/groups/420ab21a-031a-48ce-97ec-061af35ed1dd/reports/8699df09-bf84-4d0e-bf06-37d5df426f49

Report ID in the upper example is 8699df09-bf84-4d0e-bf06-37d5df426f49.

The URL parameter is the base address of the URL you got from the report URL which is https://app.powerbi.com in most cases but can be something like https://xyz.powerbi.com.

Before the final step, you need to check what is the value of the Embed Power BI Setting in the top menu. You need to set this value to Yes, otherwise, your report will not render on the form.

Your form should look something like the one below.

Once you set the settings to Yes you are ready to publish your first report on the form by pressing the Publish Report button from the upper menu.

After a few seconds, you can load your form in the browser and if you did everything right you should see the report there.

Great you have your report embedded in the form. This report is still not aware of the context of the form on which it's rendering, but we can fix that very easy.

Filtering

Click on the Filter checkbox first to enable the Filter section.

You can see 3 contacts on the report from the last example that are child records under 2 accounts.

Jane Doe and John Doe are created under the Contoso account. Ivan Ficko is created under the Span account.

We would like to filter the report based on the account record that is opened.

First, you need to open the report in the Power BI editor and find out the name of the table that you want to do filtering on. You can easily find the name by looking at the Fields tab on the right and copy the exact same name of the table that you find there. The casing of the table name is important in this step.

The table name in our case is Contacts.

The next one up is the column that you want to be filtered against the field on the actual form. The field that we are looking for here is called Account Name, but we need to find the right schema name from the fields list. The right schema name for Account Name is parentcustomerid.

The final thing here is to choose the field that will be used in the filter is the field on the Account form. We need to select accountid which will held the value of the current Account loaded on the form.

The goal is to show all Contacts that have Account Name (parentcustomerid) equal to Account ID (accountid) on the report on the form.

Finally, we can again press the Publish Report button to see the result on the form.

Let's show how the form would look like if we open the Contoso account form and confirm that only John and Jane are showing in the report.

Well done you are now ready to use the tool for other scenarios that will fit your needs.

Feedback

I hope that you will find the tool useful. Since this tool is a community tool feel free to post your feedback and ideas for features so we can make the tool even better.

Please post the issues/feature requests on the GitHub repository!