1863
Views
6
Comments
Solved
Reactive Web app- How to fetch data conditionally?
Question

Hi,

There is some if else logic before fetching data. For traditional web, i can either run server action to fetch data in preparation or put the if else login in the preparation and fetch data accordingly.

In reactive web app, how can i fetch data using server action or have logic before fetching data? 

2023-09-28 14-21-55
Daryna Kravets
Solution

Hi Peter,

You have a data in which you checks if manager already assigned, yes? 

Use it's OnAfterFetch event to add logic and trigger fetching right aggregate.

UserImage.jpg
Peter Tai

Daryna Kravets wrote:

Hi Peter,

You have a data in which you checks if manager already assigned, yes? 

Use it's OnAfterFetch event to add logic and trigger fetching right aggregate.

I was looking if there is something like before fetch event, but this could work since i am fetching other aggregate.


Thanks all.



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Peter,

You set the Aggregate or Data Action's "Fetch" Property to "Only on demand" (default is "At start"). Then if you want the Aggregate or Data Action to run, you use a Refresh Data Statement.

2019-11-11 17-10-24
Manish Jawla
 
MVP

Hi Peter,

you can check the below tutorial, it help you understand it in dept, how to fetch the data on demand in reactive web app

https://www.outsystems.com/learn/lesson/2030/fetching-data-on-demand?LearningPathId=18

UserImage.jpg
Peter Tai

Hi,

Ops maybe the title is misleading. What i wanted to know is where to put logic before fetching data.

The data action filter depend on some variable. This variable will be determined through an if else logic before running data action.

e.g. retrieving list of manager. Manager is categorized by category and seniority. 

When loading a form,  check if manager already assigned, if no , retrieve manager based on category and seniority above current user. If yes, retrieve senior manager based on category and already assigned manager.

For traditional web, i think i can put the conditions either in server action and call it in preparation or put the condition preparation before fetching data accordingly.

For reactive web, Where can i put this logic ? Also how to populate data fetched into a dropdown?


2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Peter,

I think I know what you want to know, and I gave you the solution. If you need to execute logic before fetching data, you do as I wrote above.


2023-09-28 14-21-55
Daryna Kravets
Solution

Hi Peter,

You have a data in which you checks if manager already assigned, yes? 

Use it's OnAfterFetch event to add logic and trigger fetching right aggregate.

UserImage.jpg
Peter Tai

Daryna Kravets wrote:

Hi Peter,

You have a data in which you checks if manager already assigned, yes? 

Use it's OnAfterFetch event to add logic and trigger fetching right aggregate.

I was looking if there is something like before fetch event, but this could work since i am fetching other aggregate.


Thanks all.



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