Forum Discussion

RogerT's avatar
RogerT
Frequent Visitor
8 years ago
Solved

Error in Q&A Embedded

We have a problem in our first try to embed Q&A dashboard feature.

Both the accessToken, embedUrl and the datasetIds are correct. We have checked it in the demo.

The error in console browser "uncaught exception: [object Object]" appears with the following code and only the default power bi dashboard loading icon is displayed.

 

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="es" lang="es">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<script src="../Scripts/jquery-3.2.1.js"></script>
<script src="../Scripts/powerbi.js"></script>
<title>Try</title
</head>
<body>
<script type="text/javascript">
window.onload = function () {
 
var models = window['powerbi-client'].models;
            var embedConfiguration = {
                type: 'qna',
                tokenType: models.TokenType.Embed,
                accessToken: 'H4sIAAAAAAAEACWWxw6saA...',
                embedUrl: 'https://app.powerbi.com//qnaEmbed?groupId=540ae43e-40f5-4d8a-8f39...',
                datasetIds: '4f8a276f-1288-4747-87c2-94865...',
                viewMode: models.QnaMode.Interactive
            };
            var qnaContainer = $('#qnaContainer')[0];
            var qna = powerbi.embed(qnaContainer, embedConfiguration);
            qna.off("loaded");
}
</script> 
<div id="qnaContainer"></div>
</body>
</html>  


Any ideas?

  • RogerT

    I've just tested with the datasetId, embed url etc from the demo, and below code works. In your code, you assign a datasetid '4f8a276f-1288-4747-87c2-94865...' to the datasetIds where I think an arrary is required, try to pass an array as ['4f8a276f-1288-4747-87c2-94865...'] instead.

     

    <html>
    
    <script src="jquery.js"></script>  
    <script src="powerbi.js"></script>
    
    <script type="text/javascript">
    window.onload = function () {  
    
    var models = window['powerbi-client'].models;
    
    var config= {
        type: 'qna',
        tokenType: models.TokenType.Embed,
        accessToken: 'H4sIAXXXXX',
        embedUrl: 'https://app.powerbi.com//qnaEmbed?groupId=9166cf8d-d5fc-405e-bdc7-47e414da08fe',
        datasetIds: ['ea4ad17d-bd5b-4502-a7a2-1e92e4d09532'],
        viewMode: models.QnaMode.Interactive
    };
     
    // Get a reference to the embedded QNA HTML element
    var qnaContainer = $('#qnaContainer')[0];
     
    // Embed the QNA and display it within the div container.
    var qna = powerbi.embed(qnaContainer, config);
     
    // qna.off removes a given event handler if it exists.
    qna.off("loaded");
     
    // qna.on will add an event handler which prints to Log window.
    qna.on("loaded", function(event) {
        Log.logText("QNA loaded event");
        Log.log(event.detail);
    }); 
    } 
     
    </script> 
     
    <div id="qnaContainer"></div>
    
    </html>   

     

1 Reply

  • Eric_Zhang's avatar
    Eric_Zhang
    Microsoft Employee

    RogerT

    I've just tested with the datasetId, embed url etc from the demo, and below code works. In your code, you assign a datasetid '4f8a276f-1288-4747-87c2-94865...' to the datasetIds where I think an arrary is required, try to pass an array as ['4f8a276f-1288-4747-87c2-94865...'] instead.

     

    <html>
    
    <script src="jquery.js"></script>  
    <script src="powerbi.js"></script>
    
    <script type="text/javascript">
    window.onload = function () {  
    
    var models = window['powerbi-client'].models;
    
    var config= {
        type: 'qna',
        tokenType: models.TokenType.Embed,
        accessToken: 'H4sIAXXXXX',
        embedUrl: 'https://app.powerbi.com//qnaEmbed?groupId=9166cf8d-d5fc-405e-bdc7-47e414da08fe',
        datasetIds: ['ea4ad17d-bd5b-4502-a7a2-1e92e4d09532'],
        viewMode: models.QnaMode.Interactive
    };
     
    // Get a reference to the embedded QNA HTML element
    var qnaContainer = $('#qnaContainer')[0];
     
    // Embed the QNA and display it within the div container.
    var qna = powerbi.embed(qnaContainer, config);
     
    // qna.off removes a given event handler if it exists.
    qna.off("loaded");
     
    // qna.on will add an event handler which prints to Log window.
    qna.on("loaded", function(event) {
        Log.logText("QNA loaded event");
        Log.log(event.detail);
    }); 
    } 
     
    </script> 
     
    <div id="qnaContainer"></div>
    
    </html>