In many scenarios, in case Power BI Report source data is refreshed frequently, it becomes mandatory to refresh the Power BI Reports on the page automatically. In current Power BI ShortPoint Release, there is no configuration to refresh the reports automatically. However, this workaround will help you to achieve it.
Prerequisites
- You have a valid ShortPoint License;
- You have a SharePoint page having Power BI elements embedded into it (With Master account OR Logged In User integration options);
- You are logged in with a valid ShortPoint user account.
Configuring auto refresh
Step 1
Navigate to the ShortPoint Dashboard (Site Settings > ShortPoint Dashboard) and click Сustomize my Site (Site customizations > Customize my site):
Step 2
Go to Utilities > Custom Javascript and paste the following script in custom JavaScript text area:
function waitForCounterToFinishLoading()
{
if(shortpoint && shortpoint.$)
{
if(shortpoint && shortpoint.$ && shortpoint.$('div[data-shortpoint-type=\'power-bi\']').length > 0){
console.log('Power BI Element found, refreshing the page after 5 mins!');
setInterval(function() {
window.location.reload();
}, 300000);
}
else {
console.log('Page doesnt contain any PowerBI Element');
setTimeout(waitForCounterToFinishLoading, 30000);
}
}
else{
console.log('Page doesnt contain')
setTimeout(waitForCounterToFinishLoading, 250);
}
}
waitForCounterToFinishLoading();
If you want to apply this behavior for only a specific page and not the entire site, please use below script instead of above;
function waitForCounterToFinishLoading()
{
if(location.href.indexOf('PowerBIPage.aspx') > 0)
{
if(shortpoint && shortpoint.$)
{
if(shortpoint && shortpoint.$ && shortpoint.$('div[data-shortpoint-type=\'power-bi\']').length > 0){
console.log('Power BI Element found, refreshing the page after 5 mins!');
setInterval(function() {
window.location.reload();
}, 300000);
}
else {
console.log('Page doesnt contain any PowerBI Element');
setTimeout(waitForCounterToFinishLoading, 30000);
}
}
else{
console.log('Page doesnt contain')
setTimeout(waitForCounterToFinishLoading, 250);
}
}
else
{
console.log('No Power BI Page');
}
}
waitForCounterToFinishLoading();
A Few Notes:
- Please note the highlighted text (300000) above. This is the number which indicates 5 minutes (5*60000ms). If you want to change the refresh interval for example to 1 minute, you can change above number to 60000.
- For second script, please notice the page name, you have to replace that with the page name you want to apply the script for. For example, if your page is https://shortpoint.sharepoint.com/SalesReport.aspx, you should put SalesReport.aspx in the script
- If you are using Logged In User Integration option, you need to keep in mind that the retrieved EmbeddedToken is only valid for 60 mins. So after 60 minutes, if the page is refreshed automatically, it will ask user for credentials instead of showing refreshed report with new data.
That's it! thank you for your attention.