Forum Discussion
RogerT
8 years agoFrequent 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 "u...
- 8 years ago
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>
Eric_Zhang
8 years agoMicrosoft Employee
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>