Auto Refresh web screen question

I have a chart in a web screen that is currently refreshed manually by the user clicking a button that calls a screen action. The screen action refreshes an aggregate, and then does an ajax refresh. 

Is there an easy way to automate the refresh? Ideally, I would like to refresh every 3 minutes by programmatically calling the screen action I have created. I have tried using a timer, but the timer only allows server actions to be associated with it.

Thanks for the help!


Solution

Hi Ryan,

If you're okay with small time differences, you could leave this to the browser javascript and use the setInterval function to periodically click on a hidden button and call your action. Check the espace for an example.

There's a hidden button on the page, and some javascript that clicks on it on the webscreen javascript property - the time is expressed in milliseconds, so this will cause the button to be clicked every second:

This is okay if all you're looking for is a simple periodical refresh, but you shouldn't use something like this if you need realtime refreshes or anything that requires precision.

Solution

Thank you! This is exactly what I needed. 

I found a small problem with this solution...the screen only updates when the button is set to visible. If I set the button to not be visible the screen no longer refreshes. Does anyone have any insight as to why this might be the case?

Hi Ryan,

How are you hiding the button? It needs to be with css "display:none;". because if you use the button property the button is not even render on screen.

Regards,

Marcelo

Make sure you are not setting the "Visible" property of the button. The naming of the property is a bit misleading, and if you set "Visible" to no, the button will not be included in HTML: this causes an error in Javascript.

Either create a class with CSS like "display: none;" or create a container around the button and set the "Display" property to False (the element will be included in HTML, but will not be visible).

Thank you Marcelo and Afonso. I was trying to hide the button using the 'visible' property of the button. I am now using CSS like you suggested and it works beautifully.

No problem! If you ever want to check why something goes wrong clientside, right click on a page, and look for a button that says Inspect or Console. The javascript error log will give you some clues that you can use to track down the issue.