In order to view the custom Power BI reports in F&O, we need to embed the Power BI report file to specific desired location on form.
In this blog post, we will see the process of embedding a Power BI report file into D365F&O, enabling user to view and interact with custom Power BI reports within the application.
High level steps-
- Develop a Power BI report
- Create a resource file in Visual studio of Power BI report file (.pbix file)
- Embed the resource contents using controller class on form.
- Call a controller class from form control
We presume our custom Power BI report is developed and ready to embed. We need to create a resource object in F&O and add this
.pbix file under that resource.
Once our resource file is ready, create a new controller class like below -
using Microsoft.Dynamics.AX.Framework.Analytics.Deploy.PBIPaaS;
public class DemoPowerBIController extends PBIReportControllerBase
{
// Name of the resource containing the content pack
const str PowerBIContentPackName = 'PowerBIResource';
// Name of content pack
const str PowerBIReportName = 'Demo';
//Show or hide a filter pane on report
protected boolean showFilterPane()
{
return true;
}
//Show or hide navigation pane on report
protected boolean showNavContentPane()
{
return true;
}
public PBIReportRunParameters setupReportRunParams()
{
// populate and return the report run parameters for the session
PBIReportRunParameters reportRunParams = new PBIReportRunParameters();
reportRunParams.parmResourceName(PowerBIContentPackName);
reportRunParams.parmReportName(PowerBIReportName);
reportRunParams.parmShowFilterPane(this.showFilterPane());
reportRunParams.parmShowNavContentPane(this.showNavContentPane());
reportRunParams.parmPageName(this.pageName());
reportRunParams.parmIsEmbedded(true);
reportRunParams.parmApplyCompanyFilter(false);
return reportRunParams;
}
public static void main(Args _args)
{
// initialize the controller object
DemoPowerBIController controller = new DemoPowerBIController();
controller.setupReportRunParams();
controller.run(_args);
}
public void initializeReportControl(PBIReportRunParameters _reportParameters, FormGroupControl _formGroupControl)
{
PBIReportHelper::initializeReportControlWithReportRunParams(_formGroupControl, _reportParameters);
}
initializeReportControl() method is used to initialize the Power BI report control within the user interface. It takes the PBIReportRunParameters and a FormGroupControl as parameters, and calls the initializeReportControlWithReportRunParams() method from the PBIReportHelper class.
No comments:
Post a Comment