41
Views
7
Comments
How to create an auto refreshing dashboard

Assuming you have a dashboard that display data that is affected frequently though the day. You would need to refresh the data shown regularly. However, OutSystems' DataActions and Aggregates do not have an auto refresh functionality.

DataActions and Aggregates can be refreshed in the logic flow from client side. So we want the refresh to be triggered from client side.

1. Create Refresh Action

First step is to create a flow where all the your data fetching logic is applied. Make sure it is the same logic applied when the screen is initialized, to avoid any inconstancies.

2. Define the Auto-refresh Mechanism

To define an auto refreshing behavior, we are going to use JavaScript's "setInterval" function.

setInterval: https://www.w3schools.com/jsref/met_win_setinterval.asp

We need to define the setInterval either in the "OnReady" screen event (when triggering at the start), or the "OnAfterFetch" of the DataAction or the Aggregate (if we want to fetch data once before setting auto refresh).

*Make sure to save the interval Id as we are going to need it to stop the interval later on.

3. Stop Auto-refresh

Since we are using "setInterval", we need to stop it manually using "clearInterval". 

clearInterval: https://www.w3schools.com/jsref/met_win_clearinterval.asp

In the "OnDestory" event of the screen/block stop the interval, so that it shall not be triggered when the target client action no longer active.


Finally, you can find a demo on how to use "setInterval" in OutSystems (doc "SetInterval.oml") attached to this post.

SetInterval.oml
2021-01-15 16-58-19
Sherif Diab

Very helpful

Thank you @Mustafa Emad Shaker for sharing these useful tips

2025-01-24 02-53-49
Mustafa Emad Shaker

Hope it be a useful piece of information.

2021-01-28 10-02-59
Muhammad Mahmudul Hasan

@Mustafa Emad Shaker 

Your implementation needs some modification. You need to clear interval on destroy of your page like below. 


Else it will show warning on service center you move to other page. 

2025-01-24 02-53-49
Mustafa Emad Shaker

Thanks @Muhammad Mahmudul Hasan for reviewing the post.

But I had already mentioned that the developer should stop the "setInterval" action.  In step #3, "Stop Auto-refresh", you can find in the screenshot that I used "clearInterval" in the OnDestory screen event.

Also, you can find in the 1st step, that I had saved the interval Id after I defined the "setInterval" in the OnReady screen event. And the Id is saved in a local variable visible in all screenshots, "Interval".

2025-09-28 15-31-59
Claudio Barra

Hello, while your approach works for basic scenarios, I'd like to point out that using setInterval for dashboard refreshing is actually an anti-pattern that creates unnecessary server load and doesn't scale well.

The Problem with Polling:

  • Constant HTTP requests every X seconds, regardless of whether data has actually changed
  • Increases server load exponentially with each connected user
  • Wastes bandwidth and resources
  • Creates delays in data updates (you only see changes after the next interval fires)


Modern solutions:

Server-Sent Events (SSE) - Link

WebSockets via 3rd party

SignalR via 3rd party


These approaches are event-driven: the server pushes updates only when data actually changes, rather than the client constantly asking "any updates? any updates? any updates?"


Better Architecture:

  • Client subscribes to data changes (WebSocket/SSE)
  • Server pushes updates when events occur
  • Minimal server load (one persistent connection vs. hundreds of polling requests)
  • Instant updates (no waiting for next interval)
  • Properly handles connection drops and reconnections


Greetings,

Claudio

2025-01-24 02-53-49
Mustafa Emad Shaker

Thanks @Claudio Barra for sharing this information.

I just need to mention that the logic running every X seconds was a typo, the targeted interval was 5 minutes, if the screen was still on (interval cleared when screen is destroyed).

2025-01-24 02-53-49
Mustafa Emad Shaker

I would like to hint at a correction. In the 3rd screenshot, the "refreshInterval" variable were not used, instead a of the fixed value, 1000 ms.

You can find the right code snapshot here:

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