How do I get the sort order of checkboxes in planner?
What it looks like in planner:
I get task details, and then try to figure out the order of checkboxes on that task:
GET https://graph.microsoft.com/v1.0/planner/tasks/<task id>/details
The result I get:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks('aLn7T_rxpUCOpCg0WEByJpcAJecJ')/details/$entity",
"@odata.etag": "W/\"JzEtVGFza0RldGFpbHMgQEBAQEBAQEBAQEBAQEBAZCc=\"",
"description": "",
"previewType": "checklist",
"id": "aLn7T_rxpUCOpCg0WEByJpcAJecJ",
"references": {},
"checklist": {
"16803": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": false,
"title": "4",
"orderHint": "85855241538H",
"lastModifiedDateTime": "2022-04-05T20:45:43.8795559Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
},
"20910": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": true,
"title": "0",
"orderHint": "8585524154043557016P#",
"lastModifiedDateTime": "2022-04-05T20:45:47.5743163Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
},
"24777": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": false,
"title": "3",
"orderHint": "8585524153=M",
"lastModifiedDateTime": "2022-04-05T20:45:43.246933Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
},
"44078": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": false,
"title": "5",
"orderHint": "85855241535&",
"lastModifiedDateTime": "2022-04-05T20:45:45.528325Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
},
"48712": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": true,
"title": "1",
"orderHint": "8585524153YG",
"lastModifiedDateTime": "2022-04-05T20:45:48.2150138Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
},
"70751": {
"@odata.type": "#microsoft.graph.plannerChecklistItem",
"isChecked": false,
"title": "2",
"orderHint": "8585524153Fu",
"lastModifiedDateTime": "2022-04-05T20:45:42.6364909Z",
"lastModifiedBy": {
"user": {
"displayName": null,
"id": "f551a47b-7265-4e25-a3e6-2b933b899cf6"
}
}
}
}
}
I thought that "orderHint" on checkbox is defining its order, but it does not seem to be the case:
Actual order | Order Hint |
---|---|
0 | 8585524154043557016P# |
1 | 8585524153YG |
2 | 8585524153Fu |
3 | 8585524153=M |
4 | 85855241538H |
5 | 85855241535& |
As you can see, sorting by "order hint" does not result in the actual order you can see on the screenshot above (the reverse order does not work either, the order defined by the "orderHint" strings appear to be simply random).
So, I thought maybe the order of checkboxes is defined something else then (or the API is just broken)?
OrderHint is the right property to order checklist items. The UI seems to be displaying them in reverse order. Note that the comparison needs to be "ordinal" (e.g. based on ASCII values of characters), language specific or case sensitive comparisons will produce the wrong result:
> [StringComparer]::CurrentCulture.Compare("=", "8") # language specific sort order
-1
> [StringComparer]::Ordinal.Compare("=", "8") # ordinal sort order
5