+ Start a Discussion
MikeGillMikeGill 

Auto-refresh dashboard with vpage hack

Folks,

 

I'm trying to have my dashboard automatically refresh using a visualforce page db component.

 

I have seen a s-control hack which does something what I want, but would rather use visualforce.

 

Any ideas why this doesn't work

 

 

<apex:page >
 
<html>
<head>
<script>

function onload() {
    window.parent.location.replace('/{!$CurrentPage.parameters.id}');
}

</script>
</head>
<body onLoad="setTimeout('onload()', 5000)">
    <p>Refreshing.....</p>
</body>
</html>
</apex:page>

 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
paul-lmipaul-lmi

again, has nothing to do with reloading the current page/tab.  until they expose access to the mechanism that actually triggers the dashboard refresh process, you're stuck with manually building a dashboard out of pure visualforce.

All Answers

paul-lmipaul-lmi

reloading the page doesn't refresh the dashboard.  clicking refresh on a dashboard kicks off a server side process to do all that, and the page refreshes periodically (or calls some ajax method to check refresh status), and THEN shows the data.  they designed dashboards to NOT allow you to do what you're trying to do.  we tried this same avenue, but ended up rebuilding a critical dashboard in pure VF to overcome this limitation.  this is a glaring area where Salesforce is very far from being real-time.

MikeGillMikeGill

Thanks for reply!

 

I wonder if there is a ff/chrome broswer plug-in which reloads current tab.

 

My client is looking to display the dashboard on a large screen in the office.

paul-lmipaul-lmi

again, has nothing to do with reloading the current page/tab.  until they expose access to the mechanism that actually triggers the dashboard refresh process, you're stuck with manually building a dashboard out of pure visualforce.

This was selected as the best answer
MikeGillMikeGill

Dam better get coding.

 

I have just promote the ideas too! Let's hope they add it soon.

 

thanks again

s.neil0188s.neil0188

I'm using the following visualforce component to refresh a dashboard on homepage load:-

 

 

<apex:page >
<apex:outputText value="The time right now is: 
    {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
    <apex:param value="{!NOW()}" />
</apex:outputText>
<script>
window.open('/01ZF00000001hEW?poll=1&m=HOMEPAGE&nr=1&refresh=1', 'db_refresh_frame');
</script>
</apex:page>
The dashboard id is hard coded.
The homepage can be updated as often as necessary with a 'meta-refresh' in the Messages and Alerts.

 

s.neil0188s.neil0188

...only works if pop-ups are disabled.

 

 

<apex:page >
<apex:outputText value="The time right now is: 
    {0,date,yyyy.MM.dd G 'at' HH:mm:ss z}">
    <apex:param value="{!NOW()}" />
</apex:outputText>
<script>
csol_scratch=window.open('https://na10.salesforce.com/01ZF00000001hEW?poll=1&m=HOMEPAGE&nr=1&refresh=1', 'csol_db_scratch','height=100, width=100,toolbar=no,scrollbars=no,menubar=no,titlebar=no,status=no,location=no');
window.focus();
csol_scratch.moveTo(0, 0);
csol_scratch.document.write('Updating Dashboard')
setTimeout('csol_scratch.close();',5000);
</script>
</apex:page>

 

 

displays a small 'Updating Dashboard' message. 5000 milliseconds was the estimated upper limit for time to update dashboard.

s.neil0188s.neil0188

... IE currently has issues (bug) with document.write

Surround that code with a try/catch.

MikeGillMikeGill

Great little hack - thanks.