Copy the Item and add it as a subitem to another

Has anyone had such a case where they had to make a copy of an element and place it as a subitem to another element?
Maybe someone has a query for this case, I will be grateful. Of course, if this is not possible, I will be grateful for an answer.

The second question is - is it possible to add elements via the API as mirrored fields?

Hello @mpsujek,

In this case I believe you would need to query for the column values of the subitem and then create the subitem from scratch under the new parent item via “create_subitem”.

Because you can duplicate subitems but the duplicate will appear under the same parent item as the original subitem. And then you can not “move it” to a different parent item.

Regarding the second question, what would an example of this be?

So, how to manage that?
via query mutation create_new_subitem i get only 3 columns → Owner,Status,Date
In the documentation, there is also information about column_values but no sample of how to use that.

I’ve tried that but its only create item with name New Subitem
mutation { create_subitem( parent_item_id: [my_item_id] item_name: "New Subitem" column_values: "{\"New Column\": \"Column Value\", \"Another Column\": \"Another Value\"}" ) { id } }

About mirrored fields, I’d like to match 2 different boards data via API. It’s possible?

Hello again @mpsujek,

Regarding the first question, you would get the column values from the subitem with a query like this one:

{
  items(ids:1234567890){
    name
    column_values{
      id
      title
      text
      value
    }
  }
}

You could then use that information to create the new subitem:

mutation {
  create_subitem(
    parent_item_id: 1234567890
    item_name: "My subitem"
    column_values: "{\"person\":\"someemail@example.com\", \"status\":\"Done\", \"date0\": {\"date\" : \"1993-08-27\", \"time\" : \"18:00:00\"}}"
  ) {
    id
  }
}

You have to use the column’s IDs and not their names. To get the column IDs, you can do so by clicking on your profile picture or initials at the bottom left of the screen, then clicking on monday.labs and then enabling developer mode. After that if you go to your board and click on the three dots next to your columns’ titles, you will see each ID.

You can also check them out with a query like this one:

{
  boards(ids:1234567890){
    columns{
      title
      id
    }
  }
}

You will need to pass the column values of each column in a different format depending on each column type. You can find the documentation here.

I hope that helps!

Cheers,
Matias

Hello again,

You can check the documentation about the connect boards column (which would affect the mirror column for it) here.

Let me know if you have any questions!

Cheers,
Matias