web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort a gallery using P...
Power Apps
Unanswered

Sort a gallery using ParseJSON

(0) ShareShare
ReportReport
Posted on by 111
I'm trying to order a vertical gallery, which returns the comments from the sharepoint list, as it is now, the most recent comments are displayed at the top, but I need the most recent ones to be displayed at the bottom, how do I do this?
I tried the code below, but it didn't work
 
Sort(
 Table(ParseJSON(varComments));
 Value(ThisRecord.Value.itemId);
 SortOrder.Ascending
)
Categories:
I have the same question (0)
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at
    How are you retrieving the comments, via a Send an HTTP request to SharePoint action in a flow?
     
    If that is the case you might be able to handling the sorting in the URI field by using a $orderby query parameter on the ID field
  • JasonCastro Profile Picture
    111 on at
    @Expiscornovus  thx for the help!
     

    This is my uri :_api/web/lists/getbytitle('TBL_TEST')/items(itemID)/Comments?$orderby=createdDate asc
    itemID is a dynamic item
     
    Try putting ?$orderby=createdDate asc .... but it didn't work,
     
    this is the output:
     
    {
      "d": {
        "results": [
          {
            "__metadata": {
              "id": "https://xxxx.sharepoint.com/teams/xxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(2)",
              "uri": "https://xxx.sharepoint.com/teams/xxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(2)",
              "type": "Microsoft.SharePoint.Comments.comment"
            },
            "likedBy": {
              "__deferred": {
                "uri": "https://xxx.sharepoint.com/teams/xxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(2)/likedBy"
              }
            },
            "replies": {
              "__deferred": {
                "uri": "https://xxxx.sharepoint.com/teams/xxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(2)/replies"
              }
            },
            "author": {
              "__metadata": {
                "type": "SP.Sharing.Principal"
              },
              "directoryObjectId": null,
              "email": "xxxxx@xxxxx.com.br",
              "expiration": null,
              "id": 9,
              "isActive": true,
              "isExternal": false,
              "jobTitle": null,
              "loginName": "i:0#.f|membership|xxxx.xxx@xxxxx.com.br",
              "name": "xxxxxxxxxxxxxx",
              "principalType": 1,
              "userId": null,
              "userPrincipalName": null
            },
            "createdDate": "2024-10-19T00:10:54.63Z",
            "id": "2",
            "isLikedByUser": false,
            "isReply": false,
            "itemId": 1,
            "likeCount": 0,
            "listId": "ab4d3cea-2663-46e3-866e-62556065c737",
            "mentions": {
              "__metadata": {
                "type": "Collection(Microsoft.SharePoint.Comments.Client.Identity)"
              },
              "results": []
            },
            "modifiedDate": null,
            "parentId": "0",
            "replyCount": 0,
            "text": "fghgfhfg"
          },
          {
            "__metadata": {
              "id": "https://xxxxxx.sharepoint.com/teams/xxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(1)",
              "uri": "https://xxxx.sharepoint.com/teams/xxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(1)",
              "type": "Microsoft.SharePoint.Comments.comment"
            },
            "likedBy": {
              "__deferred": {
                "uri": "https://xxxx.sharepoint.com/teams/xxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(1)/likedBy"
              }
            },
            "replies": {
              "__deferred": {
                "uri": "https://xxxx.sharepoint.com/teams/xxxxx/_api/web/lists('ab4d3cea-2663-46e3-866e-62556065c737')/GetItemById(1)/Comments(1)/replies"
              }
            },
            "author": {
              "__metadata": {
                "type": "SP.Sharing.Principal"
              },
              "directoryObjectId": null,
              "email": "xxxx.xxx@xxxx.com.br",
              "expiration": null,
              "id": 9,
              "isActive": true,
              "isExternal": false,
              "jobTitle": null,
              "loginName": "i:0#.f|membership|xxxx.xxx@xxxxx.com.br",
              "name": "xxxxxxxx",
              "principalType": 1,
              "userId": null,
              "userPrincipalName": null
            },
            "createdDate": "2024-10-18T22:42:21.183Z",
            "id": "1",
            "isLikedByUser": false,
            "isReply": false,
            "itemId": 1,
            "likeCount": 0,
            "listId": "ab4d3cea-2663-46e3-866e-62556065c737",
            "mentions": {
              "__metadata": {
                "type": "Collection(Microsoft.SharePoint.Comments.Client.Identity)"
              },
              "results": []
            },
            "modifiedDate": null,
            "parentId": "0",
            "replyCount": 0,
            "text": "TESTE 1"
          }
        ]
      }
    }
     
  • Expiscornovus Profile Picture
    33,189 Most Valuable Professional on at
    Can you use the ID to order?
     
    Try:
    ?$orderby=id asc
     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard