how to sorting rest api data?

how to sorting rest api data?

  

i want to sorting a column, but when i tried making aggregate , i get no data from the api. what should i do to sorting that column?

Hi Calvin,

After receiving the API response you can use List Sort action to sort the data based on by what column you want the data to be sorted.



Let me know if this is what you are looking for or there is something else.


Regards

-PJ-

PRAMOD JAIN wrote:

Hi Calvin,

After receiving the API response you can use List Sort action to sort the data based on by what column you want the data to be sorted.



Let me know if this is what you are looking for or there is something else.


Regards

-PJ-


how do i connect it to my ui?


Hi Calvin,

Your REST api response is stored in an OutSystems structure.

The attributes of a structure can be used as variable on input widgets or in as value in expressions. on your screens and web blocks.

A structure it self (without a repeating structure in it) can be used as Source Record on a Form.

Any repeating structure (attribute of data type xxx List) in your REST api response you can select on the Source Record List property of for example the TableRecords or ListRecords widget.

There are more widgets (wel most of them) where you can connect your data to, As long as your data is in an aggregate a record or a structure.

Regards,

Daniel

actually i want to make it clickable in my ui so 1 click to ascending and 1 more click to descending, seems like this logic can't do that

Calvin Adi wrote:

actually i want to make it clickable in my ui so 1 click to ascending and 1 more click to descending, seems like this logic can't do that

Not 100% what you want, but if it is that your have a hierarchy of data, where you want the enable the users to 'drildown' into more detail, this is possible. On your first screen, you could show the top level data in a list, and clicking on a list item you can show another screen with the related child data. This you can do as many levels down as you want. If the the data structure is repetitive you could even get this working with one screen.

So what did you try, and where did you get stuck?


Daniël Kuhlmann wrote:

Hi Calvin,

Your REST api response is stored in an OutSystems structure.

The attributes of a structure can be used as variable on input widgets or in as value in expressions. on your screens and web blocks.

A structure it self (without a repeating structure in it) can be used as Source Record on a Form.

Any repeating structure (attribute of data type xxx List) in your REST api response you can select on the Source Record List property of for example the TableRecords or ListRecords widget.

There are more widgets (wel most of them) where you can connect your data to, As long as your data is in an aggregate a record or a structure.

Regards,

Daniel

well, the problem is I can't connect structure data to aggregate, because it needs database not a structure


Hi Calvin,

Sorry but your questions keep changing, your first question was about sorting rest api data, after receiving an  you where asking how to connect it to UI, then after receiving an answer you where talking about a a specific use case on how to implement your ui logic, then the next answer you are telling that the problem is that you cannot connect structure data to aggregate.

For me I get a feeling you jumped into developing an OutSystems app, without going to the guided path training material where I think all your questions would have been answered.

I don't fully understand why you want to connect structure to data aggregate. You can populate structures with data from aggregates, but that was not subject of any of your questions.

Maybe you clearly try to explain what you try to achieve, maybe provide an .oml file so someone can help you in a more efficient way.

Regards,

Daniel



To come back to your original question, to sort the API data, you do not need an aggregate, as Pramod explained you can use list sort for that. Then the sorted response you can connect to your UI widgets. No requirement to use an aggregate.

Daniël Kuhlmann wrote:

Hi Calvin,

Sorry but your questions keep changing, your first question was about sorting rest api data, after receiving an  you where asking how to connect it to UI, then after receiving an answer you where talking about a a specific use case on how to implement your ui logic, then the next answer you are telling that the problem is that you cannot connect structure data to aggregate.

For me I get a feeling you jumped into developing an OutSystems app, without going to the guided path training material where I think all your questions would have been answered.

I don't fully understand why you want to connect structure to data aggregate. You can populate structures with data from aggregates, but that was not subject of any of your questions.

Maybe you clearly try to explain what you try to achieve, maybe provide an .oml file so someone can help you in a more efficient way.

Regards,

Daniel



i want to get a sort function to my column table like in 1.oml where it can ascending and descending, so what should I do if im using a REST API?


Hi Calvin,

So i think your question is: 

"When I receive an response from my REST API and I want to show the received data in a Table Records wizard which uses the RichWidgets\List_SortColumn for sorting columns how do make the sorting work."

The oml you provide does not contain a REST API definition nor the generated OutSystems structures that OutSystems uses to store the API response. So for me I have to make assumption again on what it is.

I assume it is a structure with repeating elements, and for each repeating element a level with more attributes (based on your previous messages).

The most easy way would be to store your API data in OutSystems entities. That way you can use OutSystems scaffolding to generate your screens and have all sorting logic in place automatically. You can then customize the screens to your need.

If you do not want to use the above solution, and connect a structure list to your table records widget, then you need to customize the destination of the OnNotify of the List_SortColumn widget. This should use the ListSort server actions to sort the list, instead of an refresh data action of an aggregate.

Regards,

Daniel

Daniël Kuhlmann wrote:

Hi Calvin,

So i think your question is: 

"When I receive an response from my REST API and I want to show the received data in a Table Records wizard which uses the RichWidgets\List_SortColumn for sorting columns how do make the sorting work."

The oml you provide does not contain a REST API definition nor the generated OutSystems structures that OutSystems uses to store the API response. So for me I have to make assumption again on what it is.

I assume it is a structure with repeating elements, and for each repeating element a level with more attributes (based on your previous messages).

The most easy way would be to store your API data in OutSystems entities. That way you can use OutSystems scaffolding to generate your screens and have all sorting logic in place automatically. You can then customize the screens to your need.

If you do not want to use the above solution, and connect a structure list to your table records widget, then you need to customize the destination of the OnNotify of the List_SortColumn widget. This should use the ListSort server actions to sort the list, instead of an refresh data action of an aggregate.

Regards,

Daniel

can you help me how to store the API data to entities? I think I need to use CreateOrUpdate but I don't understand how to use it 


Hi,

I am willing to help you, but without knowing the structure of your API response I can only describe it in global actions:

1. create entitie(s) by copying the outsystem api response structure to the database folder on the Data Tab, OutSystems wil automatically derive the entity attributes from your structure.

2. After consuming your rest API, use Create<EntityName> server action to store your api response.

3. If the response is a list you can use a foreach on the list structure to store each list entry as a record.

Regards,

Daniel

On the entity you have a property ReadOnly, it is probably set to True, if you change it to Default, you will get Create CreatOrUpdate and Delete Actions too.

Daniël Kuhlmann wrote:

On the entity you have a property ReadOnly, it is probably set to True, if you change it to Default, you will get Create CreatOrUpdate and Delete Actions too.

what property do you mean? I change the expose read-only to 'no' and nothing happened