taarskog / crm-powerbi-viewer

Embed tiles and reports from Power BI into Dynamics CRM Forms and Dashboards.
http://crm-powerbi-viewer.heiigjen.com/
MIT License
27 stars 9 forks source link

Viewer is blank when opened with Xrm.Utility.openWebResource #19

Closed peterloudon closed 6 years ago

peterloudon commented 6 years ago

Hi @taarskog

I have tried to open the viewer using:

Xrm.Utility.openWebResource("his_/powerbi/viewer.html", customParameters);

customParameters contains all of the parameters obtained from the solution configuration page and passed in the Custom Parameters when embedding in a dashboard or entity form. his_/powerbi/viewer.html is displayed, but is blank.

Is there a reason why this does not work, and is there a way to overcome that reason?

taarskog commented 6 years ago

Don't see why it shouldn't work, but I have not tried this myself.

  1. Does it work when you embed directly onto a form or dashboard (as described in the documentation)?
  2. Are you testing using a browser or is this a mobile client?
  3. Have you enabled logging (log_level=3) and what does it say?
  4. What about Adal logging (auth_log_level=3)?
peterloudon commented 6 years ago

Hi @taarskog

Thank you for replying. The answers to your questions are:

  1. Yes, it works in both form and dashboard.
  2. Testing in browsers only (Edge, IE, Chrome, Firefox (latest versions)). 3 & 4. With the logging levels set to 3, when I reload the WebResource window, I get the messages in the attached text file.

Power BI Viewer Logs.txt

taarskog commented 6 years ago

I totally forgot that openWebResource opens a new browser window. I did not create the viewer with that scenario in mind - embedding into a from or dashboard is what I have focused on. You could consider opening a window that points directly to the Power BI url.

If that does not meet your requirements I believe the fix is simply to modify how isContentFrame is set. This may have side effects as the property is used to halt processing in the case that this is an authentication frame or popup. Not able to look at this right now, but let me know if you find a good solution.

peterloudon commented 6 years ago

Hi @taarskog

Just a brief update:

  1. When I open a window that points directly to the Power BI url, (https://app.powerbi.com/reportEmbed?reportId=...) I get the Power BI logo displaying, and the code view of the window shows all the components for embedding, but nothing is displayed. It may be that I need to review the way I am doing this.
  2. When I force isContentFrame to return "true", I get the error "Invalid type. Expected 'report', 'dashboard', or 'tile'."
  3. When I embed the viewer in an iFrame, I get the error "Invalid type. Expected 'report', 'dashboard', or 'tile'."

It seems in cases 2 and 3 that the customParameters are not being correctly parsed.

peterloudon commented 6 years ago

Hi @taarskog

I now have this working as follows:

  1. Created an html web resource with XRM Page Context.
  2. Embedded the viewer in the above html web resource with the encoded parameter string appended to src.

That meets my requirement for now. So the solution was to wrap viewer in an htmal page that has XRM Page Context.