Local list is not sorted properly using ListSort function
Application Type
Traditional Web
Service Studio Version
11.9.1 (Build 33435)

Hello All,

Currently I am trying to create a page to show the total numbers of forms submitted for each category. So I have used aggregate to have 2 or 3 'group by' elements - FormName, FormTypeId (identifier datatype) and also 'Count' column and then listappend each of the record with another 2 variables - Phase and LaunchDate into the local list (a list with structure datatype, like attached screenshot below:). However, the existing list sort column widget is not working in my case. I think that is because I am not directly sorting through the aggregate, correct?

So now I am using an action to sort them, by passing the parameter(text of the column name) to that action. Both with or without the [] symbols in the parameter also work, but the list seems not sorted properly. The first row is always at the first row, the last row is always at the last row(e.g. letter 'V' should be the first row if in descending order but it is always at the last row, in the next list page).

Attached image is the first column in descending order (alphabetically) but not correct.

sortDescending.png

Champion
Solution

Hi Junior,

Please refer below OML for your solution to sort local list.

Hope it works, Thanks ;)

SortLocalList.oml

Hi Shweta,

It works for almost all columns, but for the last column which is a Long Integer(Count) dataype column seems not able to sort correctly...

Champion

What is happening with this column? Please explain

It would be great if you can share oml.

mvp_badge
MVP

Hi Junior,


Can you try to delete the sort and create it again?

When the Sort is created without Group By, it doesn't work when you after add the group by and aggregators like Count. You need to create a new Sort that will now take the Group by into account.

You can see this post which reports the exact same situation.


Hope it helps.


Regards,
João

Hi Shweta,

Some rows' number of transaction are not correctly sorted like screenshot attached(in ascending order and descending order).


forumAsking1759hrs17nov2020.png

Champion

Hi Junior,

This is happening because you have other columns as text data type so it is considering your Long Integer as text also inside if

You can use following

Apply an If before List Sort to check for your long integer attribute(In my case it Id) and apply list sort on that attribute only. Attached screenshot below

Hope this helps!!

Hello Shweta,

It works! Very appreciate your help on this concern :) 

Hi,

All you have to do is sort by the group by column then you will see the output sorted. for example below I need the output in descending order sorted on created date

Regards,

Hi Prasad,

Other than those group by columns I have 2/3 extra columns how could I sort them ? Because they are not coming from the same aggregate.

Attached is the screenshot:

Location 1: the GetFormCountByFilter aggregate is used to group the records by Form type Id, Form type name and Count for number of forms by their names.

Location 2: the GetFormCategoryById3 aggregate is used to match the Form type Id from the GetFormCountByFilter list populated from the aggregate in location 1. This is to get the category for each form group.

Location 3: the assign there is used to set what is the form type name, form type id, form category, count, and additional 2 extra attributes called 'phase' and 'launchDate' from aggregate in location 2.



Hi,

You can try to use the ListSort function on the local list variable instead. The aggregate with Group By is not work correctly in some cases

Hope this help

Hi Shingo,

Yup I have tried sorting the local list using its variables. But the rows of records are not sorted as expected. E.g. the first row and the last row always remain at the top while the rest are not all alphabetically ordered.

I dont think you can pass the column name to ListSort client action, because it should bind to the attribute in the list itself

Champion
Solution

Hi Junior,

Please refer below OML for your solution to sort local list.

Hope it works, Thanks ;)

SortLocalList.oml

Hi Shweta,

It works for almost all columns, but for the last column which is a Long Integer(Count) dataype column seems not able to sort correctly...

Champion

What is happening with this column? Please explain

It would be great if you can share oml.

mvp_badge
MVP

Hi Junior,


Can you try to delete the sort and create it again?

When the Sort is created without Group By, it doesn't work when you after add the group by and aggregators like Count. You need to create a new Sort that will now take the Group by into account.

You can see this post which reports the exact same situation.


Hope it helps.


Regards,
João

Hi Shweta,

Some rows' number of transaction are not correctly sorted like screenshot attached(in ascending order and descending order).


forumAsking1759hrs17nov2020.png

Champion

Hi Junior,

This is happening because you have other columns as text data type so it is considering your Long Integer as text also inside if

You can use following

Apply an If before List Sort to check for your long integer attribute(In my case it Id) and apply list sort on that attribute only. Attached screenshot below

Hope this helps!!

Hello Shweta,

It works! Very appreciate your help on this concern :) 

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.