OS11 Trigger server action on page load

Hi,

For OS11 mobile, what is the best method to trigger a server action to load initial values from the database.(i.e. when the screen is first rendered, and no onclick action performed).

Was looking at using the screens on initialize etc, but getting a warning regarding performance.

Thanks,

Mark

Hi Mark,

Indeed the OnInitialize as also the other screen events should not be used to fetch data.

How to do it correctly is described in the following documentation page

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Data/Query_Data/Fetch_and_Display_Data_from_the_Database

Regards,

Daniel

Hey Daniel,

Thanks for the link. 

In my case I need to do a more complex function with a number of aggregates (where some aggregates are dependent on others and order of execution) so I have a server action in my core module rather than using an aggregate.

Is there a method available to execute a server action instead?

Cheers,

Mark

Solution

Hi Mark,

On your mobile screen in service studio:

  1. Right click mouse and select Fetch Data from Other Sources
  2. In the new Data Action you can add multiple aggregates and logic, so you can also call a server action if you want from within the data action.
  3. You can define multiple output parameters that can be used (or even drag & dropped) on your screen to expose the data to your screen.

Regards,

Daniel

Solution

Hi Daniel,

Thanks for the instruction. 

Makes much more sense now. Was getting a little confused on how the parameters were made available to the screen when using the data action.

Appreciate all your help

Cheers,

Mark