TIP: How to programmably auto refresh a mobile screen

TIP: How to programmably auto refresh a mobile screen

  

Sometimes you might want to auto refresh a mobile screen, update graph, update new QR code etc

Step 1) Create a screen "MyScreen"

Step 2) Create a client action "RefreshScreen" and add a Javascript block "RefreshTimer" with the following code 

setTimeout($actions.RefreshScreen,5000); /* example will refresh screen every 5 seconds */

Next, add any logic you want to refresh

Example

Step 3) In your screen "On Initalize" event property attach this to your client action "RefreshScreen"

That's it!

Thanks for the tip!

Hi Robert, can you please provide sample app for mobile for this functionality. I am new to outsystems and trying to get this worked.

Thanks in advance

MN

- wrote:

Sometimes you might want to auto refresh a mobile screen, update graph, update new QR code etc

Step 1) Create a screen "MyScreen"

Step 2) Create a client action "RefreshScreen" and add a Javascript block "RefreshTimer" with the following code 

setTimeout($actions.RefreshScreen,5000); /* example will refresh screen every 5 seconds */

Next, add any logic you want to refresh

Example

Step 3) In your screen "On Initalize" event property attach this to your client action "RefreshScreen"

That's it!

Hi


Thanks so much for the tip. This does indeed work. I have a question though. 

Why does setTimeout() work? Shouldn't the instruction be setInterval instead? Every time the setTimeout() action runs it generates a new timeoutId. Why does the action keep on running? Shouldn't setTimeout() only run once?

Thanks in advance for the attention


Regards,

   Carlos LSJ