This is because the subitems exist on a different board.
You need to make a query to retrieve the subitem column:
{
boards(ids: boardid) {
columns {
id
title
settings_str
}
}
}
Note: that if you know the column id for the subitem column, you can enter this directly, it is generally just subitems but it can change, i.e. in my example the column id issubitems9. But I believe the title will always be “Subitems” which you can filter through in the results.
The settings_str will contain a value similar to this:
I was able to access the subitem columns from the query editor, but when I try this from my app, I get the error
[{“message”:“Permission Denied! Your token doesn’t grant access to workspaces:read”}]
Even though my query does not request anything at the workspace level.
export const MONDAY_ITEMS_WITH_SUBITEMS_QUERY = `query fetchItemsWithSubItems($itemIds:[Int],$subItemBoardIds:[Int]){
boards(ids:$subItemBoardIds) {
name
workspace {
id
}
columns{
id
title
settings_str
type
}
}
items(ids:$itemIds){
id
name
name
column_values{
id
value
additional_info
type
}
subitems{
id
name
column_values{
id
value
additional_info
type
}
}
}
}`
I am running this query after fetching all the items on the main board. The first input is the itemIds, and the second input is the boardIds corresponding to the subitems.
The first part of the query is to get the subitem columns, and the second part is to get the subitems from items.
This query started working well after I gave the workspace:read permission
I hope this is useful.
The reason you recieved the Permission error was due to you querying the workspace ID.
export const MONDAY_ITEMS_WITH_SUBITEMS_QUERY = `query fetchItemsWithSubItems($itemIds:[Int],$subItemBoardIds:[Int]){
boards(ids:$subItemBoardIds) {
name
columns{
id
title
settings_str
type
}
}
items(ids:$itemIds){
id
name
name
column_values{
id
value
additional_info
type
}
subitems{
id
name
column_values{
id
value
additional_info
type
}
}
}
}`
Remove the workspace { id } from your query and you will be all good!