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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Power BI Report Server - Refresh data on embedded report

Hi -

 

Below, we have figured out the javascript code that can be pasted into the console to get a PowerBI Report Server report to refresh the data only (i.e. clicking the refresh button) on a timer. We can get this to work whether you are on the regular screen of the report server report or with it in the embed view, but not when it is actually embedded.

 

The use case would be to provide "real-time" data using report server so that these reports could be kept open, refreshed, and the dropdown choices stay as the user selected. 

 

Does anyone know how to get this code below to work when embedding a report on a website on an internal network?

 

Thank you!

 

function refreshPowerBI() {

this.frames[0].postMessage({kind:"powerbi.reportServerHost.IToolbarActionMessage",button:"refresh"},"https://[our report server]:443")

}

 

if(window.autoRefreshInterval) { clearInterval(window.autoRefreshInterval); };

window.autoRefreshInterval = setInterval(refreshPowerBI, 60*1000)

10 REPLIES 10
Nicolas687
New Member

Hello, I am using this solution on the September 2021 release.
So far it worked without any issues.
This is the code I was using so far.

<iframe marginwidth="0" marginheight="0" width="100%" height="100%" scrolling="yes" frameborder=0 id="iframe" src="http://rMyrapport?rs:embed= true">
</iframe>
<script>
function shift()
{
this.frames[0].frames[0].postMessage({kind:'powerbi.reportServerHost.IToolbarActionMessage',button:'refresh'},'*');
}
setInterval(shift, 10000);
</script>


But we installed the May 2022 version.
Since this update, this code no longer works.
Do you know why and especially how to correct.

Have you figured that out?

Anonymous
Not applicable

<iframe style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden;" frameborder=0 id="iframe" src="http://your-url:8080/Reports/powerbi/your-report:embed=true">
</iframe>
<script>
function refresh()
{
this.frames[0].frames[0].postMessage({kind:'powerbi.reportServerHost.IToolbarActionMessage',button:'refresh'},'*');
}
setInterval(refresh, 120000);
</script>
</html>

Hi Vincentt,

 

I'm trying to get this to work with the September 2021 release of the PBRS. However, I'm not able to get the report to refresh using the code as you've included in your example. I was very optimistic when I used the new Desktop for the Sept2021 PBRS that includes an automatic page refresh feature. However, it seems to only be valid for the Desktop and not when uploading to the PBRS. Unfortunately! And I do not understand why this feature is included only in the Desktop...

 

But back to the case: On which versions and configurations did you get this to work?

I'm very intersted learning how to come around this hurdle!

 

Thanks,

-A

Have you figured it out?

Hi there,

 

Unfortunately, not.

We've moved away from using Power BI for such kind of dashboards for now. Some time ago, this refresh ability was added to the Desktop version for Report Server, however it did not work when deploying the dashboard to the server.

 

I guess this will change with time, and actually, I've not tested the latest versions for an update on this.

Could you tell me what other tool you used for this kind of dashboards instead of Power BI?

 

Thanks.

For the most we've established realtime dashboards by use of Python and Dash (Dash Documentation & User Guide | Plotly).

 

It is not as easy as drag-n-drop for the Open Source version. The Enterprise has quite some wrappers and I believe also a WYSIWYG editor.

 

Good luck!

-A

Anonymous
Not applicable

You'd need to inject the script onto the page and call the function. I was able to get this working by using an iframe to host the inject call. You can do this by placing a custom html page in the wwroot folder of report server and then embedding the report into that html page. A sample of the code I used is below.

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>page title</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge;" />
<base href="/">
<meta charset="utf-8">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no" />
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var frame = '<iframe src="your report url" id ="powerbiframe" name="powerbiframe" onLoad="injectJS()" runat="server" height="100%" width="100%" frameborder="0"></iframe>';
$("#framecontainer").append(frame);
})

</script>
<script>
function injectJS() {
var iFrameHead = window.frames["powerbiframe"].document.getElementsByTagName("body")[0];
var myscript = document.createElement('script');
myscript.type = 'application/javascript';
myscript.src='dashrefresh.js';  //save your powerbirefresh function to a .js file in the same location as your html file
iFrameHead.appendChild(myscript);
}
</script>

</head>
<body>
<div id="pbi-loading"></div>
<div>
<ui-view></ui-view>
</div>
<div id="reportcontainer" align="center">
<div id="framecontainer"></div>
</div>
</body>
</html>

 

Where/how do I find the wwwfolder you're talking about?

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.