Refresh screen aggregate on creation of record

Hello,

My reactive app exposes a REST API that creates records in an entity. The screen uses an aggregate to query that entity and assign its output to a local list variable. I'm currently using a JavaScript function that calls a client action that refreshes the aggregate every 3 seconds. Is there a way to refresh the screen aggregate only when a record is created in the entity so that I don't have to query every 3 seconds?

Thank you!

Hi Robert,


I think you need to use some websocket tools to push the changes from server to clients in the real time.

Have a look to this plugin https://www.outsystems.com/forge/component-overview/10677/reactive-pusher-client

So you can trigger the pusher function whenever there is a change in your backend entities data, and then using the JS you can handle this event and refresh the aggregate.


Regards,

Hasan

This plugin looks like what I need. Thanks Hasan!

Hello Robert

Can't we use the Refresh Data Widget after inserting data in entity with Rest API? 

Something like this to update the Aggregate - 

I don't think I can refresh the screen aggregate from the REST function because it is not in scope. See attached image -- there is no refresh data widget available.


I can use a screen client-action to refresh the aggregate at a specific interval, but is there some way for the screen to know when the entity changes (e.g. some kind of entity OnCreate event)?


Can you try to call this Server Action in a Client Action and the data refresh widget will be added there Just after this Server Action. 

Like shared in the above example, I have called the server action in Client action

Sorry, I'm not following you. I know I can call a server action in a client action, but how does that relate? Here is the flow:

1.) Another app calls the REST function.

2.) The REST function creates a record in an entity.

3.) The screen needs to refresh its aggregate to that entity.

In step 3, since the screen doesn't know when the REST function is called, how can it know when to refresh the aggregate?

Ahh, sorry I was getting the scenario in another way which is wrong and now I understand the correct way. You will need to use the Socket to achieve this. Please look into this forum discussion - https://www.outsystems.com/forums/discussion/70673/pusher-messagereceived-not-working/# 


It was kind of same requirement. We had to refresh the Dashbaord and receive notification if anything happen in relevant entity. I had discussion with Arun and then we took help from Arley. 

I'm sure that discussion will be a good reference. Thanks for the help Manish!

Hi Robert,


I think you need to use some websocket tools to push the changes from server to clients in the real time.

Have a look to this plugin https://www.outsystems.com/forge/component-overview/10677/reactive-pusher-client

So you can trigger the pusher function whenever there is a change in your backend entities data, and then using the JS you can handle this event and refresh the aggregate.


Regards,

Hasan

This plugin looks like what I need. Thanks Hasan!

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