26
Views
5
Comments
Sorting a list  in api call on after fetch is not reflecting in the UI list widget
Question
Application Type
Mobile

Hi , 

I am getting a list from api response which is an array of JSON objects. 

I need to sort it according to the dates. I am using ListSort in OnAfterFetch and list is sorted successfully. But when i use it in the screen List widget.. not able to get the sorted list in the UI List Widget.


This is my onAfterFetch action .   and trying to use in the below expression container of my list .. but it is showing unsorted date. 

2023-07-10 13-24-07
Ang Lee Chuan

Hi Sunku,

If possible, would you be able to share your file so we are able to see what is causing the issue?

2020-09-21 08-42-47
Vincent Koning

Is your table connected to the ReporteesSorted variable? And not to the aggregate?

UserImage.jpg
Sunku Sai Purnima

ReporteesSorted is a list type of local variable that has the sorted list .. i am using this in the List widget on my screen.

2025-04-15 04-00-33
Prakhar Sharma

Hi @Sunku Sai Purnima

I have few questions here. 

1. Why are you using list sort inside of a loop? List sort doesn't return any output list as it will automatically sort the list based on the condition provided.

2. Why do you need another "ReporteesSorted" variable to store the sorted list as you can directly bind your UI with the main list which you initially sorted.

Directly sort the "Reportees" list without putting it in any loop and bind it directly with the UI. This should probably work.

Regards,

Prakhar Sharma

UserImage.jpg
Sunku Sai Purnima

My requirement is ReporteesList  is of type 

[

  {

    "employeeId": "114775",

    "name": "Puja Jha",

    "job": "Senior Test Engineer",

    "emailAddress": "puja.jha@bahwancybertek.com",

    "journeyList": [

      {

        "transactionId": "TRNDOM011964",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel",

        "travelType": "Domestic",

        "startDate": "2023-12-21 16:06:00",

        "endDate": "2023-12-22 16:06:00"

      },

      {

        "transactionId": "TRNDOM011966",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel",

        "travelType": "Domestic",

        "startDate": "2023-12-20 12:38:00",

        "endDate": "2023-12-21 12:38:00"

      },

      {

        "transactionId": "TRNDOM011977",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Test",

        "travelType": "Domestic",

        "startDate": "2023-12-22 21:52:00",

        "endDate": "2023-12-23 21:52:00"

      },

      {

        "transactionId": "TRNINT011956",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel testing ",

        "travelType": "International",

        "startDate": "2023-12-20 13:27:00",

        "endDate": "2023-12-21 13:27:00"

      },

      {

        "transactionId": "TRNINT011958",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Testing ",

        "travelType": "International",

        "startDate": "2023-12-20 15:59:00",

        "endDate": "2023-12-21 15:59:00"

      },

      {

        "transactionId": "TRNINT011960",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel test",

        "travelType": "International",

        "startDate": "2023-12-22 16:52:00",

        "endDate": "2023-12-23 16:52:00"

      },

      {

        "transactionId": "TRNDOM011976",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel",

        "travelType": "Domestic",

        "startDate": "2023-12-22 10:57:00",

        "endDate": "2023-12-23 10:57:00"

      },

      {

        "transactionId": "TRNINT011978",

        "projectCode": "90006",

        "projectName": "Marketing - BCT Support",

        "purpose": "Travel",

        "travelType": "International",

        "startDate": "2023-12-25 11:29:00",

        "endDate": "2023-12-26 11:29:00"

      }

    ]

  }

]


The outer list has details that has to be listed in the list screen .. and i have to display the start date of the journey list of inner object that is sorted and also i need to print the end date of the last journey from the journey list



So for each of the outer element i am sorting the journey list to get first start date.. in the onAfterFetch when i used message box to display in the client action .. it is showing sorted start date but when i use the same list in the widget .. its not showing the sorted one. 

ReporteesSorted i just tried to fix the issue.. 

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