Refresh UI component on DB update

748 views Asked by At

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?

2

There are 2 answers

0
Hanno On BEST ANSWER

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!

1
Manarjan Singh Ghai On

Best option would be to something like socket.io

Socket.io is a good bi-directional client server communication js library which can "emit" events the client can "listen" to.

It is non blocking and real time

Socket IO

Run Javascript on outsystems