Hi @darkmift,
Welcome to the community 👋
You can follow the format used in this example and the mutation will run! I will also paste the same query I tested it with (but replaced with my own IDs) below 🙂
mutation SetVolunteerInRequesterItem {
change_multiple_column_values(
item_id: 1317064012
board_id: 1317064001
column_values: "{\\"date42\\": {\\"date\\": \\"2023-11-30\\", \\"time\\": \\"08:00:00\\"}}"
) {
id
}
move_item_to_group(group_id: "new_group73364", item_id: 1317064012) {
id
}
}
Let us know if you have any other questions!
Best,
Rachel
Hi Rachel,
Tyvm for your prompt assistance!
Im pasting here for any future visitors:
mutation SetRequesterMultipleValues {
change_multiple_column_values(
item_id: 1317064012
board_id: 1317064001
column_values: "{\\"connect_boards5\\":{\\"linkedPulseIds\\":[{\\"linkedPulseId\\":1316953659}]},\\"date42\\" : {\\"date\\" : \\"2023-11-30\\", \\"time\\" : \\"08:00:00\\"}}"
) {
id
}
move_item_to_group(group_id: "new_group73364", item_id: 1317064012) {
id
}
}
A strong suggestion, is create the “column_value” as an object in your code, then serialize it to JSON and use the string in the query. This will avoid needing to worry about ensuring everything is escaped correctly.
I also suggest looking at GraphQL variables: https://graphql.org/learn/queries/#variables
The below example assumes you’re setting API-Version to 2023-10 (not shown in the code). The advantage of variables is you do not need to worry about string substitutions and ensuring everything is properly escaped. As you see I also am serializing values
to JSON to meet the requirement that column_values be a JSON string (denoted by the $values: JSON! for the variable definition). API 2023-10 uses ID type rather than Int type, ID can be a string or integer. Note that right now the item ID in linkedPulseIds must be an integer but I’ve heard that is getting fixed soon since its a bug. One reason for using strings, is that is how the IDs are returned by the API.
const query = `mutation (
$boardId: ID!,
$itemId: ID!,
$values: JSON!,
$groupId: ID!)
SetRequesterMultipleValues {
change_multiple_column_values(
item_id: $itemId,
board_id: $boardId,
column_values: $values) {
id
}
move_item_to_group(group_id: $groupId, item_id: $itemId) {
id
}
}`;
const variables = {
boardId: "1317064001",
itemId: "1317064012",
values: JSON.stringify({
connect_boards5: {linkedPulseIds: l{linkedPulseId: 1316953659}]},
date42: {date: "2023-11-30", time: "08:00:00"},
})
};
await mondayClient.api(query, {variables});
Yup it was really a formatting issue but using request-graphql really helps since it will auto cast where needed.
github.com
something not to forget is monday’s API doesn’t adhere to the graphql spec regarding errors. It returns some errors according to the spec but many it creates error_message and error_code key in the response. I’ve brought it up several times but it seems to fall on deaf ears that having four different ways they return their errors breaks using spec compliant clients to their full capability.