another way for API to get an aggregate data

another way for API to get an aggregate data

  

So I used server action to get the data 1 by 1 and then create that to the cloud database. the thing is in my preparation its always start with connect to the API first, so even though I edit or delete the data in database, because I connect to the API first, the data can't be edited. any solution? I uploaded my oml too.


Hi Calvin,

For what use case you need to call the API in the preparation?

Marco Arede wrote:

Hi Calvin,

For what use case you need to call the API in the preparation?

here's my server action

so If im not using this action in preparation, I got zero data in my entity database.

Hi Calvin, 

Could you please tell me why you are going to save the data on DataPost list page preparation. What is your requirements. Because every time you run that Datapost page then preparation will call and try to crate entity in the database and then you got error. 


-Hitesh

Hitesh Maran wrote:

Hi Calvin, 

Could you please tell me why you are going to save the data on DataPost list page preparation. What is your requirements. Because every time you run that Datapost page then preparation will call and try to crate entity in the database and then you got error. 


-Hitesh

I want to get the data from restAPI https://jsonplaceholder.typicode.com/posts, and mapping it to entity database so I can make an aggregate function to that data . I ask how to do that in other thread and thats the answer that I got.


Hi Calvin,

I'd not advise to do that in the preparation and instead:
1) or load in database those records before going to that screen - you can have a process that loads data
2) or enter that screen and then load the records - you can do it using a screen action

Regards,

Marco Arede wrote:

Hi Calvin,

I'd not advise to do that in the preparation and instead:
1) or load in database those records before going to that screen - you can have a process that loads data
2) or enter that screen and then load the records - you can do it using a screen action

Regards,

sorry, can you give an example for that? 


Calvin Adi wrote:

Marco Arede wrote:

Hi Calvin,

I'd not advise to do that in the preparation and instead:
1) or load in database those records before going to that screen - you can have a process that loads data
2) or enter that screen and then load the records - you can do it using a screen action

Regards,

sorry, can you give an example for that? 


Hi  Calvin,

I would advice you to create one timer, which can be used to sync(insert data into entity) from the web service.

Either you can schedule your timer to run automatically in certain interval Or you can write the code to wake the timer on screen action bind with a button or link.

Sachin


Hi Calvin,

In case you need more information or examples, there is already an explanation about how to do it here:

https://www.outsystems.com/forge/component/495/how-to-lazy-load/

Regards,

Marco Arede wrote:

Hi Calvin,

In case you need more information or examples, there is already an explanation about how to do it here:

https://www.outsystems.com/forge/component/495/how-to-lazy-load/

Regards,

there's no explanation in that link


Sachin Mahawar wrote:

Calvin Adi wrote:

Marco Arede wrote:

Hi Calvin,

I'd not advise to do that in the preparation and instead:
1) or load in database those records before going to that screen - you can have a process that loads data
2) or enter that screen and then load the records - you can do it using a screen action

Regards,

sorry, can you give an example for that? 


Hi  Calvin,

I would advice you to create one timer, which can be used to sync(insert data into entity) from the web service.

Either you can schedule your timer to run automatically in certain interval Or you can write the code to wake the timer on screen action bind with a button or link.

Sachin


but make an timer doesn't solved my problem sir


Solution

If your intention is to bootstrap the entity from api, you can use the same logic as how it's being done when bootstrapping from excel

1. Create a timer and set the Schedule property to "When Published"

2. Inside the timer, in between start and end - add the tampungPost server action 

3. Lastly, remove the tampungPost at preparation.

This will populate the data after a published has been made and not every time page load which is what you currently have right now. What's happening is that when the page is reload, it repopulate your entity and overrides any update you made that's why you can't see any of the modification you've made.

Solution

John Alvin Salamat wrote:

If your intention is to bootstrap the entity from api, you can use the same logic as how it's being done when bootstrapping from excel

1. Create a timer and set the Schedule property to "When Published"

2. Inside the timer, in between start and end - add the tampungPost server action 

3. Lastly, remove the tampungPost at preparation.

This will populate the data after a published has been made and not every time page load which is what you currently have right now. What's happening is that when the page is reload, it repopulate your entity and overrides any update you made that's why you can't see any of the modification you've made.

thanks, it worked now! I don't know we can schedule some action like that

Calvin Adi wrote:

Marco Arede wrote:

Hi Calvin,

In case you need more information or examples, there is already an explanation about how to do it here:

https://www.outsystems.com/forge/component/495/how-to-lazy-load/

Regards,

there's no explanation in that link


Hi Calvin,

Inside the link there is a component with an example on how to do a load of content in a load of a page using a late load.

Then, in case you want a correct way of doing without a timer, you can use the RichWidget component List_LateLoad, that will call the OnNotify action of your screen to load the API content.

Good luck and regards,