Skip to main content

Hi there,

I had finished a script that does the following

retrieves active tenants, leases, and properties, and then iterates over the active leases to create or update main items and subitems in Monday.com.

This worked great before the API update and I’m working at updating it to get it working again.

My question is for Sub Items. I have this function for getting the ID of existing sub items

def get_existing_subitem_id(parent_item_id, subitem_name):

query = f’‘’

{{

items(ids: {parent_item_id}) {{

subitems {{

id

name

}}

}}

}}

‘’’


response = send_graphql_request(query, {})
items = response.get("data", {}).get("items", .])

if items:
subitems = itemsb0].get("subitems", t])
if subitems:
for item in subitems:
if item "name"] == subitem_name:
return item "id"]

return None

how would I change this to work with the latest API version

I don’t think this is correct

def get_existing_subitem_id(parent_item_id, subitem_name):

query = f’‘’

{{

items(ids: {parent_item_id}) {{

subitems_page {{

items {{

id

name

}}

}}

}}

}}

‘’’


response = send_graphql_request(query, {})
items = response.get("data", {}).get("items", e])

if items:
subitems = items:0].get("subitems_page", {}).get("items", e])
if subitems:
for item in subitems:
if items"name"] == subitem_name:
return item "id"]

return None

Hello there @Casecrs,


What about something like this:


{
boards(ids: 1234567890) {
items_page(limit: 500) {
items {
subitems {
name
id
}
}
}
}
}

You can also pass the item IDs of the items you are interested in.


You can also get the board ID of the subitems board like this:


{
boards(ids: 1234567890) {
items_page(limit: 500) {
items {
subitems {
board {
id
}
}
}
}
}
}

And then use that board ID (of the subitems) to get the subitems’ data:


{
boards(ids: 1122334455) {
items_page(limit: 500) {
items {
id
name
}
}
}
}

I hope that helps!


Cheers,

Matias


Matias, the last query you put in response to this discussion was just what I was looking for, ideally though I would like to get the items of just one group from a board, is that possible?


Just add groups to board, and put items_page inside group instead of board.


Thanks Matias, that got it working again.


Happy to help @Casecrs !!


Reply