Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Salesforce Embed Throwing Error from Power BI JS Library

We have had an embedded Power BI report Lightning Web Component running for a few months, so far with just one report being displayed. Recently we tried to add another report but it appears that this report is causing an error to be thrown from within the PowerBI javascript library that we have as a static resource in the Salesforce org.

 

The embed token is being retrieved, and the report begins to render, but then throws multiple instances of the same aura component error. It appears that these graphics may be causing the isssue.

 

Each of these components throw its own error, showing as an aura error modal. From that modal:

 

Uncaught Error in $A.getCallback() [a.indexOf is not a function]
throws at https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:129:15. Caused by: Error in $A.getCallback() [a.indexOf is not a function]
{anonymous}()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:944:191
b()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:946:72
$.C.ta()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:944:311
a()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:1025:196
{anonymous}()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:1025:389
Proxy.<anonymous>()@https://mycompany--test.lightning.force.com/auraFW/javascript/2yRFfs4WfGnFrNGn9C_dGg/aura_prod.js:100:90760
Object.raiseCustomEvent()@https://mycompany--test--c.visualforce.com/resource/1650479333000/PBIJS/PBIJS/PBIJS.js:1389:19
Service.handleEvent()@https://mycompany--test--c.visualforce.com/resource/1650479333000/PBIJS/PBIJS/PBIJS.js:619:21
eval()@https://mycompany--test--c.visualforce.com/resource/1650479333000/PBIJS/PBIJS/PBIJS.js:146:21
Object.routeRecognizerHandler()@https://mycompany--test--c.visualforce.com/resource/1650479333000/PBIJS/PBIJS/PBIJS.js:9777:46

 

 

We are using v2.11.0 of the PowerBI js library.

Code snippets, including line numbers from the above stack trace:

 

Router.prototype.registerHandler = function (
                    routeRecognizer,
                    method,
                    url,
                    handler
                  ) {
                    var routeRecognizerHandler = function (request) {
                      var response = new Response();
9777                    return Promise.resolve(handler(request, response)).then(
                        function (x) {
                          return response;
                        }
                      );
                    };
this.router.post("/reports/:uniqueId/events/:eventName", function (
              req,
              res
            ) {
              var event = {
                type: "report",
                id: req.params.uniqueId,
                name: req.params.eventName,
                value: req.body,
              };
146           _this.handleEvent(event);
            });
if (embed) {
              var value = event.value;
              if (event.name === "pageChanged") {
                var pageKey = "newPage";
                var page = value[pageKey];
                if (!page) {
                  throw new Error(
                    "Page model not found at 'event.value." + pageKey + "'."
                  );
                }
                value[pageKey] = new page_1.Page(
                  embed,
                  page.name,
                  page.displayName,
                  true /* isActive */
                );
              }
619           utils.raiseCustomEvent(embed.element, event.name, value);
            }
          };
function raiseCustomEvent(element, eventName, eventData) {
          var customEvent;
          if (typeof CustomEvent === "function") {
            customEvent = new CustomEvent(eventName, {
              detail: eventData,
              bubbles: true,
              cancelable: true,
            });
          } else {
            customEvent = document.createEvent("CustomEvent");
            customEvent.initCustomEvent(eventName, true, true, eventData);
          }
1389       element.dispatchEvent(customEvent);
        }

 

 After that, the stack trace leads into the aura js source, which is minified.

10 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    In this case it turned out to be an issue with the report setup in Power BI, not in Salesforce. Another individual handles that for my organization, so I don't remember the exact nature of the problem, sorry.

    • vrieza_rhmn's avatar
      vrieza_rhmn
      New Member

      what do you mean on report setup? can you approach the individual pls? i need help

       

      _____

       

      or can you post your newer version of those code above?

    • seanrich's avatar
      seanrich
      Regular Visitor

      FYI for any future lurkers! I encountered this same issue with my Salesforce admin. We have a number of Power BI reports deployed to a single Power BI workspace, with only one of them throwing the error that OP shared. I double-checked that all of the settings for the reports were the same, so I opened the report in question locally in Power BI desktop.

      After checking all of the visuals in the report, including hidden visuals, I found that one in particular was referencing a column that was not present in the data model, as the visual was part of a visual group that was copied and pasted from another report. I changed the column reference to a column present in the data model, republished, and my Salesforce admin confirmed that the report was working again.

      All of this to say, there is likely an error with a visual in the report somewhere. Just a reminder to check all visuals, whether visible or not.

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    Community Support

    Hi Anonymous,

     

    What is the content of the error details. Please make sure you register your application correctly and get the token.

    Embed content in your Power BI embedded analytics application - Power BI | Microsoft Docs

    Maybe this link will be helpful to you.

    Power BI (Embed dashboard with Vue.js and Power BI REST API using Postman). Part 4 (Embed with Vue.js). | by Tetiana Farhuts | Medium

     

    Best Regards

    Community Support Team _ chenwu zhu

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks for the reply! I think I have the application registered correctly, as I am receiving a token and embed url from Power BI. However, the embedded application appears to throw an error while rendering the report/graphics.

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi,

        I am facing a similar issue. Were you able to find any solution?

        Thanks

        Garima Singh