Search code examples
outsystems

Refresh UI component on DB update


I have an exposed REST API and an UI component (Label) in outsystems.

The REST API insert some data on database.

So, my requirement is, when my external application insert a data using REST API in outsystems the UI component update its value automatically (real-time).

How it is possible in outsystems?


Solution

  • You can start a process on an insert on an entity. But this will not refresh the UI.

    To refresh the UI, you can use Javascript to refresh the page periodically.

    You need to add two expressions to the page. The first one at the top of the page (i.e. first element in MainContent section), and the second one in the Footer section.

    Add some Javascript to the expressions as the Value.

    • First expression: "<script>function refresh(){setTimeout(function(){ $('#"+RefreshButton.Id+"').click();refresh(); }, 5000);};</script>"
    • Second expression: "<script>refresh();</script>"

    NOTE: Remember to set Escape Content to No on both expressions!