Need To Call RestAPI While launching Mobile screen

Hi,

  I am new to OutSystems, I have an Rest API so need to Load that Rest API While Launching that Screen. Right now I have implemented that Rest API while Hitting the Button or any action performed and it is working fine. My scenario is have to load Rest API while launching screen in Mobile APP.

Thanks,

Mohan

You can use a data action. Just right click on your screen, add a data action, drop the call in the flow and specify the right output parameter.

In mobile the screen life cycle is like

1) On Initialize(Events occurs on page call )

2)On Ready(Prepares the data to display on the screen similar to preparation in the web)

3)On Render(Events occur when data rendering on screen)

4)On Destroy(Events occurs when the current page is going out of scope usually we will use for removing event listeners)

So as per your requirement you have to create action which calls an API and you have to assign this action "On Initialize"of the screen

Hope this will helps you.

Regards,

Koushik.

Hi,

As Roman suggest, 

using DataAction is a right approach to call API. It will be executed as soon as your screen launch & the good thing is it is called automatically & Asynchronously.

Call your respective API in the DataAction Call.

Thanks,

Assif


Hi Mohan Natchimuthu,

A note on Kushik's post, you can find here detailed information on the screen lifecycle events, when will they be triggered and what kind of logic you should have in the handlers (if you need them). Calling Web Services on an OnInitialize is usually considered a bad practice, as that will delay feedback to the user: you want OnInitialize to be lightweight so it doesn't keep the screen from rendering for long.

Like Roman and Assif suggest, it is better to call web-services from Data Actions as those are called asynchronously and don't stop the application from displaying the screen. Once the Data Action finishes executing, if you're using its outputs on Screen it will automatically get refreshed.

Roman wrote:

You can use a data action. Just right click on your screen, add a data action, drop the call in the flow and specify the right output parameter.


How to specify the right output parameter


Solution

You should to set the datatype that you need, drag the rest api call into the action flow, assign results of your rest api call to the output parameter. After that you can use it on your screen like this: DataAction1.Out1. Hope this helps


Solution

Roman wrote:

Mohan Natchimuthu wrote:

Roman wrote:

You should to set the datatype that you need, drag the rest api call into the action flow, assign results of your rest api call to the output parameter. After that you can use it on your screen like this: DataAction1.Out1. Hope this helps


Hi Roman, I tried, but it is not working for me can you give me a sample for me i will add a url which I have in below. thanks.


http://www.mocky.io/v2/5c5c05ec3900009a15e05960


Can you share your oml file? What exactly is not working? 



thnx the reply Roman... it is working fine now :)..