How to reload a ScreenAction every 30 seconds with JavaScript?

Hi guys,

How  to reload a ScreenAction every 30 seconds with JavaScript?

Solution

Hi Diego,

Create one button in screen with hide style (Create one destination action and refresh the div by ajax ).
And add java script in expression to refresh the particular screen on your specific interval.

"<script type=""text/javascript"">

function refeshPage(){
    $('#"+ btn_Refresh.Id +"').click();
}
var RefresthTimer = 10*60*1000;//minutes by seconds (add your time interval)

jQuery(document).ready(function() {
    // refreshing value
    setInterval(refeshPage, RefresthTimer);
});
</script>"


Thanks,

Manish Pandey

Solution

Hmm, I think the cleanest solution would be, to have a webblock, which notifies every 30 seconds, then on the notify you can trigger your server action.

You can also try using a timer which clicks a hidden button or changes some value in a hidden input and trigger your server action on the submit or on change.

Hello Diego,


You have this component on forge, called Auto Refresh Utils, https://www.outsystems.com/forge/2134/


Hope it helps,

Cristiano Chamorra

Hi Diego,


https://www.outsystems.com/forge/component-overview/195/light-ajax-refresh i also available  on forge.


Regards,

Amreen

Hi Diego Souza,

The easiest solution to refreshing the page is to add this inside the head:

<meta http-equiv="refresh" content="30" />

to refresh it every 30 seconds.

You can do similar with Javascript by doing:

setTimeout('window.location.href=window.location.href;', 30000);
setTimeout('window.location.reload();', 30000);
setTimeout('history.go(0);', 30000);

Both of these will completely reload the page every 30 seconds.

Hope this helps!
Thanks

Hello Diego Souza

Using JavaScript setInterval() function you can achieve your destination.

Manish Pandey wrote:

Hi Diego,

Create one button in screen with hide style (Create one destination action and refresh the div by ajax ).
And add java script in expression to refresh the particular screen on your specific interval.

"<script type=""text/javascript"">

function refeshPage(){
    $('#"+ btn_Refresh.Id +"').click();
}
var RefresthTimer = 10*60*1000;//minutes by seconds (add your time interval)

jQuery(document).ready(function() {
    // refreshing value
    setInterval(refeshPage, RefresthTimer);
});
</script>"


Thanks,

Manish Pandey

Thank you Manish Pandey