Hello @ilja and welcome to the community!
I hope you like it here 💪
As of today the only way of doing this is by creating a subitem in your board using the UI and then creating the subitems via API.
I will add your vote to the request of the feature for creating a subitem column via API 🙂
Cheers,
Matias
Please consider this one at higher priority.
I’ve just learned python, and basic programming just to learn your api, and now know more about GraphQL and discovered all of the logical ways of solving a very similar problem to the poster here are not supported.
There’s no way to setup a master template, pushing changes to boards created from it today.
So the natural next idea was to create the template and use the “move to board” option, this is not supported by the API yet.
Then I figured out how to simply create new the entire board change I needed, how to scale it to hundreds of boards ( which all have unique hard to find identity IDs ) and associate with the extremely obfuscated workspace association, and now I have a script capable of finally pushing all of this to all of these boards, and I run into this error.
‘There is no subitem column on this board, please add it first’
I need to be able to scale this platform and I’m not going to manually step into hundreds of our boards just to enable something that should be an option by default, please consider providing a workaround and forwarding this to your engineering team.
Hi! Is this still the current situation regarding? I am having difficulty creating sub-items as well.
Hello @Ozzy and welcome to the community!
I hope you like it here 💪
Would you be able to please send over the mutation you are using and the response you are getting?
Looking forward to hearing from you 🙂
Cheers,
Matias
Thanks for the response! I do like it here! Here is the current mutation (for Creating a Subitem w/ variables.)
`
mutation ($parentItemId: ID!, $subitemName: String!, $columnValues: JSON!) {
create_subitem(
parent_item_id: $parentItemId,
item_name: $subitemName,
column_values: $columnValues) {
id
name
column_values {
id
value
}
board {
id
}
}
}
`;
The response that I am getting is:
Error creating subitem: [
{
message: 'Type mismatch on variable $parentItemId and argument parent_item_id (Int! / ID!)',
locations: [ [Object] ],
path: [ 'mutation', 'create_subitem', 'parent_item_id' ],
extensions: {
code: 'variableMismatch',
variableName: 'parentItemId',
typeName: 'Int!',
argumentName: 'parent_item_id',
errorMessage: 'Type mismatch'
}
}
]
This response suggest to me that I need to change the argument type of “parent_item_id” to Int!, but when I do the whole function fails and the request is not sent.
In my API call headers, I added in version 2023-10 (based on this snippet from API docs for subitems.)
(Subitems)
Hello again,
That’s odd, it is working well for me. Could it be maybe a typo in your variables or something similar?
What I used:
Headers: API-Version: 2023-10
GraphQL body:
mutation ($parentItemId: ID!, $subitemName: String!) {
create_subitem(
parent_item_id: $parentItemId,
item_name: $subitemName, ) {
id
name
column_values {
id
value
}
board {
id
}
}
}
Variables:
{
"parentItemId": 1234567890,
"subitemName": "MySubitem"
}
Example in JS:
var myHeaders = new Headers();
myHeaders.append("Authorization", "MYAPIKEYHERE");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("API-Version", "2023-10");
var graphql = JSON.stringify({
query: "mutation ($parentItemId: ID!, $subitemName: String!) {\\n create_subitem(\\n parent_item_id: $parentItemId,\\n item_name: $subitemName, ) {\\n id\\n name\\n column_values {\\n id\\n value\\n }\\n board {\\n id\\n }\\n }\\n }",
variables: {"parentItemId":1234567890,"subitemName":"MySubitem"}
})
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: graphql,
redirect: 'follow'
};
fetch("https://api.monday.com/v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
Let me know if the example helps!
Cheers,
Matias
Thank you! That helped as I am now able to add the subitem.
However, I was also trying to pass my column values as a variable. When I add that variable in my query, I get basically the same original query I had that does not function. It returns a "TypeError: Cannot Read Property ‘create_subitem’ of undefined.
Here is my query:
mutation ($parentItemId: ID!, $subitemName: String!, $columnValues: JSON) {
create_subitem(
parent_item_id: $parentItemId,
item_name: $subitemName,
column_values: $columnValues) {
id
name
column_values {
id
value
}
board {
id
}
}
}
Hello again,
I just tested it and could create a subitem using this:
Headers: API-Version: 2023-10
GraphQL body:
mutation ($parentItemId: ID!, $subitemName: String!, $columnValues: JSON) {
create_subitem(
parent_item_id: $parentItemId,
item_name: $subitemName,
column_values: $columnValues) {
id
name
column_values {
id
value
}
board {
id
}
}
}
Variables:
{
"parentItemId": 1234567890,
"subitemName": "My new subitem",
"columnValues": "{\\"status\\": \\"Done\\"}"
}
JS:
var myHeaders = new Headers();
myHeaders.append("Authorization", "MYAPIKEYHERE");
myHeaders.append("Content-Type", "application/json");
myHeaders.append("API-Version", "2023-10");
var graphql = JSON.stringify({
query: " mutation ($parentItemId: ID!, $subitemName: String!, $columnValues: JSON) {\\n create_subitem(\\n parent_item_id: $parentItemId,\\n item_name: $subitemName,\\n column_values: $columnValues) {\\n id\\n name\\n column_values {\\n id\\n value\\n }\\n board {\\n id\\n }\\n }\\n }",
variables: {"parentItemId":1234567890,"subitemName":"My new subitem","columnValues":"{\\"status\\": \\"Done\\"}"}
})
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: graphql,
redirect: 'follow'
};
fetch("https://api.monday.com/v2", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
“TypeError: Cannot Read Property ‘create_subitem’ of undefined” sounds to me like there might be an issue with the script and maybe not with the mutation itself, since that does not look like a message coming from monday’s server, but rather from the script itself. I would check that as well.
Let me know how that goes!
Thank you again! I think there is something wrong with my column values, as I am able to create the sub-item with the correct name (and under the correct Parent item ID). But then when I add the ColumnValues variable to my query, that is when I get the script error.
Here is the columnValues JSON string I am using - does anything look weird to you in this?
columnValues:
{"date":"Mon Feb 06 00:00:00 GMT-05:00 2023",
"text":"Sat Dec 30 17:30:00 GMT-05:00 1899",
"text92":"1 Towne Centre Blvd",
"text7":"Fredericksburg",
"text84":"Virginia",
"text20":"22407.0",
"text5":"Spotsylvania"}
Hello again @Ozzy,
It looks like the date you are passing is not in the right format.
You need to pass a value such as: "2019-06-03 13:25:00"
You can check everything about the date columns here.
Let me know how that goes!
Cheers,
Matias
Thank you! It is working as intended now. Your help is much appreciated!