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.

Afonso Carvalho wrote:

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.


Hi Afonso,

I am trying to do auto refresh by add Javascript to webscreen :

setTimeout('window.location.reload();', 30000);

, its great. However, it seems it is actually clicking a button which sends emails so at every reload an email is sent. Any pointers are appreciated.


Best Regards,

Ashima


Hi Ashima,

Not knowing what your page does, I'm guessing you have a button that sends emails there, and you've clicked it once before your auto refresh kicks in. 

I'm assuming what's happening is form resubmission - when you submit a form on a page and then refresh it manually, most modern browsers will warn you about this. There's two ways to avoid it here:

 - use an action that sends you to the same page instead of using location.reload() - something similar to what I wrote above;

 - have your email sending button send you to the same page instead of stopping with an End node.

In the future, consider opening a new post! Most users won't read old and answered posts, you'll be able to get more answers with a fresh post.