Api Query to list view

trying to format api json result to show comments and replies

ex.
Comment
Reply
Reply

Comment

JSON Response
"@odata.context": "https://graph.microsoft.com/v1.0",
"@odata.count": 2,
"value": [
{
"id": "16658526dafs40855",
"replyToId": null,
"etag": "1665852640855",
"messageType": "message",
"createdDateTime": "2022-10-15T16:50:40.855Z",
"lastModifiedDateTime": "2022-10-15T16:50:40.855Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": null,
"importance": "normal",
"locale": "en-us",
"webUrl": "Join conversation",
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "ea6be1e1-a539-415d-a991-adsf",
"displayName": "adf",
"userIdentityType": "aadUser",
"tenantId": "e6dddc4a-1c3d-4d17-99c2-adsf"
}
},
"body": {
"contentType": "text",
"content": "test 2"
},
"channelIdentity": {
"teamId": "3f59f1aa-edbd-401d-adf-af",
"channelId": "19:asdf@thread.tacv2"
},
"attachments": [],
"mentions": [],
"reactions": [],
"replies@odata.context": "https://graph.microsoft.com/v1.0/$metadata#teams('afd-edbd-401d-ae51-adsf')/channels('19�%40thread.tacv2')/messages('adf')/replies",
"replies@odata.count": 1,
"replies": [
{
"id": "1665852744750",
"replyToId": "1665852640855",
"etag": "1665852744750",
"messageType": "message",
"createdDateTime": "2022-10-15T16:52:24.75Z",
"lastModifiedDateTime": "2022-10-15T16:52:24.75Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": null,
"importance": "normal",
"locale": "en-us",
"webUrl": "Join conversation",
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "ea6be1e1-a539-415d-a991-2908ce548fed",
"displayName": "sfd asdf",
"userIdentityType": "aadUser",
"tenantId": "asdf-1c3daf4d17-99c2-asf"
}
},
"body": {
"contentType": "text",
"content": "test 3"
},
"channelIdentity": {
"teamId": "3f59f1aa-edbd-asfd-ae51-af",
"channelId": "19:asfd@thread.tacv2"
},
"attachments": [],
"mentions": [],
"reactions": []
}
]
},
{
"id": "1665852475049",
"replyToId": null,
"etag": "1665852475049",
"messageType": "message",
"createdDateTime": "2022-10-15T16:47:55.049Z",
"lastModifiedDateTime": "2022-10-15T16:47:55.049Z",
"lastEditedDateTime": null,
"deletedDateTime": null,
"subject": null,
"summary": null,
"chatId": null,
"importance": "normal",
"locale": "en-us",
"webUrl": "Join conversation",
"policyViolation": null,
"eventDetail": null,
"from": {
"application": null,
"device": null,
"user": {
"id": "dsf",
"displayName": "asdf",
"userIdentityType": "aadUser",
"tenantId": "e6ddasdf170"
}
},
"body": {
"contentType": "text",
"content": "test"
},
"channelIdentity": {
"teamId": "3f59f1aasdfef03fc",
"channelId": "19:2447fadsfcv2"
},
"attachments": [],
"mentions": [],
"reactions": [],
"replies@odata.context": "https://graph.microsoft.com/v1.0asdf",
"replies": []
}
]
}

JavaScript Query
var d = query1.data.value
var outArr = []
d.forEach((a) => {
outArr.push({
id: a.id,
body: a.body,
replies: [{
body: a.replies
}]
})
})

return outArr;

Listview Text
This gives me all comments but no replies
{{query2.data[i].replies[i].body[i].body.content}}

This give me the comment with the reply but nothing else
{{query2.data[i].replies[i].body[i].body.content}}
{{query2.data[i].body.content}}

Hey @nroeder!

How are replies to each comment indexed? It looks as though it could be either at data.replies or data.replies[0].body or both! As both are arrays in the sample data you sent over. In either case, this seems like a good use case for nested listviews which have a slightly different indexing structure which you can read about here. Essentially, instead of using i, you'll want to reference ri[x] where x is the level of listview nesting you're referring to. For instance, ri[0] refers to the component's position in the outermost listview while ri[2] refers to the component's position in the innermost listview (assuming you've nested three layers deep).

In this case you can try something like setting the original message content using {{query2.data[ri[0]].body.content}} and then referencing replies using something like {{query2.data[ri[0]].replies[ri[1]].body[0].body.content}}:

Though you might want to use another layer of nesting and go with something like {{query2.data[ri[0]].replies[ri[1]].body[ri[2]].body.content}} !

Let us know if that works?