Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building 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
)
  • Expiscornovus Profile Picture
    31,643 Most Valuable Professional on at
    Sort a gallery using ParseJSON
    Can you use the ID to order?
     
    Try:
    ?$orderby=id asc
     
  • JasonCastro Profile Picture
    111 on at
    Sort a gallery using ParseJSON
    @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
    31,643 Most Valuable Professional on at
    Sort a gallery using ParseJSON
    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

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard