Forum Discussion
Power BI Report Server - Refresh data on embedded report
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?