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 = items[0].get("subitems", [])
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", [])
if items:
subitems = items[0].get("subitems_page", {}).get("items", [])
if subitems:
for item in subitems:
if item["name"] == subitem_name:
return item["id"]
return None