Add await to outsystems
206
Views
20
Comments
New
Service Studio

Hi,
Outsystems is async oriented, but sometimes, we need to guarentee that an Action/Aggregate B is not started/fetched, till Action/Aggregate A is finished.
Thus, we need this feature to "organize/orchester" the execution as needed.
Adding await or finally, could help, but any other solution is more than welcomed.

Kind regards,
Sirajeddine

It is possible when you set Aggregate B fetch on "on demand", and the fetch of Aggregate A to "At Start"

In the "OnAfterFetch" of Aggregrate A, you refresh Aggregate B.

Be sure that in de "OnParameterChanged", you only refresh Aggregate A, because Aggregate B is refreshed in the OnAfterFetch of A

Hi Marlies,

Thanks for your reply. I know this already but actually in some use cases we need both aggregates to be fetched at start.

Kind regards,
Sirajeddine

@Sirajeddine Bouasker ,

what Marlies is proposing is the exact mechanism you are asking for, making one wait for the other.

Why would this not be what you need ?  



Also,

besides controlling the orchestration explicitly, if one DataAction or Aggregate makes use of the output of the other, and both have Fetch = AtStart, they will wait for each other at start.  

However refreshing the first later on will not automatically also keep the second in sync, so solution by Marlies is probably preferred for most if not all use cases.

I totaly agree with @Marlies Quaadgras . 
But if you want to do things sequentialy and you don't want to use OnAfterFetch, put it in a data action.

I agree with @Dorine Boudry's proposed solution.

Thank you all, in my use case I have 3 aggregates in the same screen, they are interconnected, and as the process is async, we don't know which one will be first fetched (finished fetching), so which one to put At start? and which one to put On demand?
Another thing is that, we want to fetch them all together At start, because the Products aggregate, is using Components aggregate, and both are used in the Orders aggregate.

Kind regards
Sirajeddine

So first Orders then Components and then Products

Yup Dorine is right.

Summarizing : 

3 aggregates , first Components fetched "on start"  with "on after fetch" action that refreshes Products which in turn has a "on after fetch" action that refreshes Orders   . 

Products and Orders are fetched "on demand". As the Components runs on start, the others will run on start too. 

Remember that the need of change from Components triggers the need of refreshing Products and Orders, and need of change from Products  triggers the need of refreshing  Orders, to maintain things in sync.


No need of a component I believe

@Maria da Graça Peixoto Thank you for your reply, still couldn't understand your solution

@Sirajeddine Bouasker ,

I propose you open a forum post asking the community how to do this.  It's easier to just show in a demo oml, but those can't be added to ideas.

If you agree that this is not an idea for improvement but just something you don't know how to do yet, ask an mvp to close this idea as 'out of scope'.

@Dorine Boudry Thank you, still there are other use cases for await, not only aggregates.
So, I think the idea makes sense even if there is another solution for aggregates.

Kind Regards,
Sirajeddine

Another use case is for example an aggregate of exams, each exam has a list of questions (second aggregate), each question has a list of possible answers (third aggregate), and when I select the exam, I need its questions to be fetched, when I select a question, I need its possible answers to be fetched, could anyone please tell me how to do it ?

Kind regards,
Sirajeddine

Dear Sirajeddine, 

I agree with Dorine that you should make a forum question for this. Also there are a lot of questions like this, asked and answered in the forum, so may be you can search there.

But in this case: in the field on the screen where you change the question, you create a "on change" client action. In this client action you refresh the aggregate with the answers (which are based on the selected question).

Best regards, Marlies

Thank you @Marlies Quaadgras 

https://www.outsystems.com/training/courses/?Page=2&f=523bb51c-a1e6-4e6d-8ed2-8449e1a5581e

Let's take the following scenario:
I have a dropdown tag widget, in which the user introduce student's email, I need to fetch this employee data, so in a cycle (For each) I need to find the corresponding id, then fetch student by id ( which is actually a userId, since student is a user indeed), this is done via first aggregate inside the foreach cycle.
Then, I need to get tests (exams) done by this employee. 
Then I need also to fetch questions related to each exam + possible answers of each question + student's selected answer.
As the relationship between Student and Exam is many to many, I created another Table: take-exam: which has then 2 FKs: StudentId and ExamId.
I need to fetch it, whenever an exam is assigned to a student by adding his email in the dropdown tag.
What happens is that it works for first exam, but then, for second exam, the id of the exam remain the same as the previous one, so it doesn't fetch it.
Could you please tell me how to do it properly?

Kind regards,
Sirajeddine

@Sirajeddine Bouasker 

Again, take note of the suggestions Dorine and Marlies made regarding asking questions for helping develop something:

This page is a place for ideas on improving the OutSystems product. Not for asking help during your own application development. That's the Forum intended to be.

You should definitely create a forum post with those questions, as we can help a lot more efficiently (we can share .oml files with examples).

Most probably you are not keeping track of the correct ExamId.

But I don't know for sure if that's the issue, because you can't provide an example .oml file here.
So, 3rd time's the charm, please create a forum question (here) and add your current application as .oml file.

Hi Jeroen,

Thanks for your answer, OK I will create a question in the Forum, but it is not a matter of ExamId, for sure.

Regards