I’d like to query subitems where a date column matches a date range. This is possible for regular items by using items_page
queries. Is this not possible at all for subitems? Any feasible workarounds?
Back in 2020 I think the answer was no.
I’d like to query subitems where a date column matches a date range. This is possible for regular items by using items_page
queries. Is this not possible at all for subitems? Any feasible workarounds?
Back in 2020 I think the answer was no.
You can but you must get the subitem board ID first, then use item_page on THAT board, rather than the main board ID.
You can get the subitem board ID from
{
boards(id: 123123){
columns(ids: "subitems") {
settings_str
}
}
}
settings_str is a JSON string you can parse, and there is a boardId property (or boardIds) which contains the subitem board ID.
This query tends to be the easiest to get the ID.
Now you can query that subitem board as if it was a regular board.
Ahhh, that clears it up. I saw people talking about such a subitems board, but I wouldn’t have thought to look in the settings string. Cheers Cody!
The other way to get it to query an item for its subitems and have the subitems include their board ID. I don’t like this method because it results in retrieving items we don’t need and uses up more API complexity (plus since you may not know an item ID to retrieve on the board, you have to do an items_page with a limit of 1 on the board.) It gets messy that way. But I’m sharing it since it may be useful in other settings possibly.
{
items {
subitems {
board {
id
}
}
}
}
Thank you for the help @anon29275264 !!!
I wanted to add here that you want to avoid directly querying the subitems
column. I made the assumption this is a magic column ID, but the column ID is different depending on the language of the user that created the board! Query by column type instead:
boards(ids: [123]) {
columns(types: subtasks) {
id
}
}
Don’t forget the settings_str
to extract the subboard ID:
boards(ids: [123]) {
columns(types: subtasks) {
id // This can be eg. sous__l_ments (for Sous-éléments)
settings_str
}
}
You’re right. It was a magic ID for several years, and always subitems
until a few couple months ago!
Then all the sudden without any notice monday started generating it as subitems__1
or such.
At least there is only one subtasks column - for now. But I can imagine if they added a feature to support multiple types of subitems that there could be more of them. They better think that through first…