1532
Views
8
Comments
Solved
How  to reload a ScreenAction every 30 seconds with JavaScript?
Question

Hi guys,

How  to reload a ScreenAction every 30 seconds with JavaScript?

Rank: #2646
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

Rank: #1399

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


Champion
Rank: #104

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.

Staff
Rank: #435

Hello Diego,


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


Hope it helps,

Cristiano Chamorra

Rank: #403

Hi Diego,


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


Regards,

Amreen

Rank: #357

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

Rank: #219

Hello Diego Souza

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

For reactive:

Make a refresh button on your screen.

Add a javascript on render:

On Render

  setInterval(function(){ document.getElementById($parameters.InputId).click(); }, 2000);