Reactive Web app- How to fetch data conditionally?

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? 

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.

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

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?


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.


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.

Solution

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.