Aggregate Filter from Other Aggregate Record
Application Type
Reactive
Platform Version
11.11.0.27350

Hi!

Let's say I have two aggregates with Fetch "On Start".

When I use a record from the first aggregate, in the filter of the second aggregate, will OutSystems fetch the first Aggregate in the first place?

Does OutSystems do it automatically, or do I have to fetch Agg1 On Start, set Agg2 On Demand, and refresh on After Fetch of Agg1?

Thank you!

mvp_badge
MVP
Solution

Hello there Pedro,

Hope you're doing well.


If you have two Aggregates with Fetch "At start", they will be executed in parallel. Of course, one of them will finish its execution first, but both are executed asynchronously and at the same time. So there is no guarantee that one is going to be executed after the other.


In this case, if you have an Aggregate that fully depends on another one, so you have to ensure that the second Aggregate only runs after the first one finishes its execution (the Platform doesn't do this automatically).


So you should indeed consider your second option:

  • Aggregate1 runs "At start" of the screen;
  • Aggregate2 is set to run "Only on demand";
  • Aggregate1 has an OnAfterFetch event where you should refresh your Aggregate2.


Kind regards,

Rui Barradas

Hi,

the data fetch is Assync, so, in my point of view, it's better the second option to have shure that the filter data already exist.


Hope this can help.


Best regards,

Ricardo M Pereira

Champion

Hi Pedro

Aggregates run parallelly in react app. If you want to execute Aggregates  in an order,

Maybe you can create a single server action (Fetch Data from Other Sources), and move Aggregates to this action.

Hope it could help you.

Kind Regards,


mvp_badge
MVP

Hello Tom,

That suggestion will surely work. But moving the Aggregates to a Data Action will lead to some losses in terms of performance.

Optimizations that the Platform execute automatically for Aggregates won't apply if they are inside a Data Action.


Kind regards,

Rui Barradas 

mvp_badge
MVP
Solution

Hello there Pedro,

Hope you're doing well.


If you have two Aggregates with Fetch "At start", they will be executed in parallel. Of course, one of them will finish its execution first, but both are executed asynchronously and at the same time. So there is no guarantee that one is going to be executed after the other.


In this case, if you have an Aggregate that fully depends on another one, so you have to ensure that the second Aggregate only runs after the first one finishes its execution (the Platform doesn't do this automatically).


So you should indeed consider your second option:

  • Aggregate1 runs "At start" of the screen;
  • Aggregate2 is set to run "Only on demand";
  • Aggregate1 has an OnAfterFetch event where you should refresh your Aggregate2.


Kind regards,

Rui Barradas

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