I would like to filter subitems items by column value, is it possible without going over all items in the group.
Hello there @gilaidoc and welcome to the community!
I hope you like it here
You can use a query like this one, using the board ID of the subitems board:
{
items_page_by_column_values(
limit: 50
board_id: 1234567890
columns: [{column_id: "status", column_values: ["Done"]}]
) {
cursor
items {
id
name
}
}
}
If you don’t know the board ID of the subitems board, you can use something like:
{
boards(ids: 111111111) {
items_page(limit: 500) {
items {
subitems {
board {
id
}
}
}
}
}
}
Cheers,
Matias
Adding to the original poster’s question… If I want to return only the items of a board where the items contain a subitem with a status column with a value of “set” (for example) is this possible using the items_page or items_page_by_column_values method? Basically, the column to be filtered on is a subitem column, but it doesn’t seem that subitem columns are not in scope for either of these approaches. Is this true?
on the query of the subitems board, this is a fragment of the query you can put in where relevant.
items {
parent_item {
id
}
}
The filter should be apply to the subitem column not the parent
i would like to get the subitem with column_id and value [“Done”]
Hello there @gilaidoc and @paul-enoda
The solution I gave using items_page_by_column_values uses the subitems board. Not the main board.
I want to filter for all subitems with a specific parentItemId and a specific sub-column value.
How would I be able to do this?
You’ll need to first query the parent item’s subitems column to get a list of subitems for the item, there is no direct filter for parent item in an items_page query. ( I prefer getting just subitem IDs from the subitems column rather than the subitems object of the item, much less API complexity and the worst you have to do is parse some JSON from the value of the subitem column)
You can then perform an items_page or items_page_by_column_values on the subitems board, and then process the results to filter only those items where its ID is included in the subitems list you got.
It requires some processing on your side possibly. You may be able to specify the subitem IDs as an IDs argument of the items query under the items_page query to filter it on the monday side. I haven’t tried that one yet though.
either way its going to take two calls, one to get the list of subitem IDs, then to query the subitems board. Within that you’ll end up filtering it either via monday query or on your client side.