128
Views
12
Comments
Solved
Multiple Fetching Data on Screen Without Call All Aggregate in Preperation
Application Type
Traditional Web

Hallo All,


I have screen like this

For the first time this page is loaded will fetch aggregate "Name" from preperation and will showed in UI as table records, but I have 2 more data that should be fetched while I click the button. When I click button Address will fetched aggregate "Address", when I click button Age will fetched aggregate "Age".

I have tried to call three aggregate in preperation like this

But I don't want to do it like that because when the page is loaded it will feel heavy because it immediately calls 3 aggregates.

Is there another way if I want to fetch only the required aggregates?


Thanks

2023-02-20 05-20-57
Nam Nguyen
Solution


This way is more straightforward.

Just modify your preparation like this. 
Your logic stays the same. 



Cheers,


Nam

2023-02-20 05-20-57
Nam Nguyen

Hi Kane Loony, 

In Preparation, you only fetch aggregate "Name".

In TabClickEvent,  you define an action to refresh data

For example, "Address", 
You create a local variable IsAddressFetched ( False as Default).

In the handle action for TabClickEvent :

if  IsAddressFetched  -> end
else :  

IsAddressFetched  = True;
GEtdata;

Ajax refresh

2023-02-20 05-20-57
Nam Nguyen
Solution


This way is more straightforward.

Just modify your preparation like this. 
Your logic stays the same. 



Cheers,


Nam

2020-11-13 06-20-57
Kane Loony

Hi Nguyen,

Can you share more details what Tab Click Event? because i using button to fetch data and change table records

Thanks

2023-02-20 05-20-57
Nam Nguyen

When I looked at your picture, I thought that you were using Tab Widget, So I suggested fetching data in TabClickEvent cause it is an event of Tab Widget.

But then I realize that there is an easier way. 
you just ignore my first comment and focus on the second comment. 


In the second comment, you only need to update the preparation as I mentioned above.

The If Clause is set to False



The actions that associate with your button are refreshing data and changing table records.


Cheers,

Nam
 


2020-11-13 06-20-57
Kane Loony

Hi Nguyen,

When I set condition to false it's mean preperation just fetch 1 aggregate. My question is when I click button Age how can I fetch Age aggregate on preperation?

Thanks

2023-02-20 05-20-57
Nam Nguyen

Hi Kane Loony,

You refresh data (use the "refresh data" action), it is possible. Please try it and verify it yourself.


From my point of view and the scenario that you shared, I don't see why fetching all data at the preparation. You only need to fetch GetName. When you click the button Address, you fetch GetAddress and then change table records. The same thing with Age.
The reason is I don't see the usage of GetAddress or GetAge when the screen renders its first time.

Cheers,

Nam
 



2020-11-13 06-20-57
Kane Loony

Hi Nguyen,

Awesome... your idea it's work like I want. I thought if I want to fetch data from aggregate, I have to enter flow in preparation, but it's not. by using the data refresh action I can also fetch data even though it is not included in the flow preparation.

Thanks

2023-08-28 07-00-10
Paulo Torres
Champion

Hello,

You can use a condition IsLoadingScreen().

After Name query you out a IF with this function, True goes to the end false will run the queries!

This function tell you if you are opening the screen for the first time.

Regards

2020-11-13 06-20-57
Kane Loony

Hi Paulo,

Can you share more details about IslLoadingScreen()

Thanks

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Kane Loony 

As i understood, You only want to GetName aggregate in preparation, 

Before that make sure you don't need other 2 aggregates data when screen load, fetching data in preparation means the data which required for initial view without any event triggered (i.e. OnClick or onChange)

So, GetAge and GetAddress not required initially and these data required after any event like click on any button then you can call these aggregate on you event handler,

Like there is a button Show Address so when you click this button a handler action called then you can put your GetAddress aggregate there and pass current person id to get address,

Or if you have relation between these 3 aggregate you can join these 3 together in a single aggregate also.

I hope it'll help you,

Thanks
Deep

2020-11-13 06-20-57
Kane Loony

Hi Dubey,

You right!,  First thing to do when UI loaded just get aggregate name, if click another button will get another aggregate another, so the first time UI is loaded it will feel light because it's only fetching 1 aggregate. But I really confused how to do this

Thanks

2024-09-12 02-43-38
Deepsagar Dubey

Hi @Kane Loony 

Just remove GetAge and GetAddress aggregate from preparation, then Create 2 link or button in each row and pass GetName.current.youraggregate.id as input parameter in button or link onclick event handler screen action.

Then these action will give you address and age,

But my suggestion is that if you have relationship in all 3 tables then you can create only 1 aggregate and join them so you'll get all data.

I hope it'll help you.

Thanks
Deep

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