Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
RogerT
Frequent Visitor

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>  

QAErrorReport.png
Any ideas?

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
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>   

 

View solution in original post

1 REPLY 1
Eric_Zhang
Employee
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>   

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.