Deleting subitems

Hello there,

First post in the developer section.
I’m trying to figure out how to write a code in GraphQL for deleting subitems.

I’m reading this description (Items) and I note this quote “Using this board ID and subitem ID you can apply any action to the subitem as you would to a regular item (i.e. archive it, delete, change column_values, etc).” and it’s not clear to me what syntax I’d have to use to delete (not to create) a sub item (not an item).
Would it be something like this:

mutation {
    delete_subitem (parent_item_id: 1234567, item_name: "subitem to be deleted") {
        id
        board {
            id
        }
    }
}

or something like this with the parent item id inserted somewhere?

mutation {
    delete_item (item_id: 12345678) {
        id
    }
}
1 Like

Hey @iszabo ,

That’s a great question!

The short answer to this is: just use the Sub-item ID. :slight_smile:

To put this into perspective, any Sub-item board in a monday.com account is just like any other board. You can see the items and columns of that sub-item board, and those can be separate from the Parent/Main item board.

When querying a Board, you can get all of the Items and Sub-item IDs:

Then, you can just use the sub-item ID in order to delete it:

Does that make more sense? Let us know :slight_smile:

-Alex

I think it does and thank you for taking the time to answer. I’ll have a crack at this and report back.

1 Like

@iszabo

Awesome :slight_smile: I’ll be keeping my fingers crossed, but if you have any further questions on this, just let us know.

-ALex

Just curious… has there been an update on this code? I would love to see it if there has!

Sorry, I failed to deliver on my promise! I actually ended up going down a different path and asked for Integromat support’s help. It’s been done with a series of modules linked to each other. It is a working solution, but I imagine it would be much more simple to just write a code for it. I did not have the time to keep trying that avenue unfortunately. I can share what Integromat modules were used if you’re interested.

1 Like

Hello @jailynnlucidday and @iszabo!

I have a question for you, why is the delete_item method (which also works for subitems) not an option in your cases?

Looking forward to hearing from you :slightly_smiling_face:

Cheers,
Matias

I would be interested in that !

This to me is a good foundation for code that can expand to other things that I have been waiting for in subitems. While I have used the Delete subitem automation with custom automations there are a few things I want to see through and possibly find my own work around for. That includes the following:
Change all subitem dates according to the change in the parent item
Change all subitem {column} that matches {column} in the parent item

Really I think that this is a good foundation to get the subitems to the full capability that I find useful in many cases, and I would love to have a solution for these common issues.

Hello Matias,

I dunno, I started writing the code into a GraphQL module on Integromat and it started throwing errors when I run it. I had no idea how to resolve those and after a couple of tries I just lost my patience. Went to Integromat’s helpdesk for advice and they’ve helped me with solving the problem with modules, not code.

Sure.
This is what the structure looks like:


In short, the way it operates is the following:

  1. Webhooks gets triggered when the status of an item changes to something. (I have a Monday automation that changes the status of the main item if the status of a subitem changes.)
  2. I get all the respective subitems (since subitems are a separate board or something) listed by the next module.
  3. The Iterator takes all the subitems from the subitems board into an Array.
  4. Not really sure of why there was a need for a Get an Item module but it’s placed after the Iterator.
  5. There’s a filter in place between the Get an Item and the Delete or Archive an Item module that makes sure only those subitems get deleted that are part of the parent item that triggered the Webhook.
1 Like

Hi!

I am glad you could find a workaround using Integromat!

As for our API, you can always use delete_item to delete a subitem.

And regarding other features for subitems, I will share this feature requests with our team :slightly_smiling_face:

Cheers,
Matias