How  to reload a ScreenAction every 30 seconds with JavaScript?
Question

Hi guys,

How  to reload a ScreenAction every 30 seconds with JavaScript?

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

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

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.

For reactive:

Make a refresh button on your screen.

Add a javascript on render:

On Render

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


Make a refresh button on your screen.

Add a javascript on render:

On Render


var btn = document.querySelector($parameters.ButtonId);

setInterval(function(){

btn.click();

}, $parameters.Interval * 1000);


or You can use forge Component directly:


https://www.outsystems.com/forge/component-versions/10593/version/0/platform/11

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.