Hello @McMurry!
Regarding the clearing of a checkbox column, you can use a mutation like this one:
mutation {
change_multiple_column_values(item_id: 1234567890, board_id: 1122334455, column_values: "{\\"checkbox\\" : null}") {
id
}
}
Hope that helps!
Cheers,
Matias
Hi Matias, Apologies; I wasn’t clear, null is the first permutation I tried
I’m iteratively passing each of the failing values into the method below. Unfortunately, Google apps script won’t work with the raw api syntax; it has to be pretty close to pure javascript.
function testParameterEncoding(permutation) {
var query =
'mutation{change_column_value(' +
'board_id: ' + Board_id + ",item_id:" + Item_id +
',column_id: "checkbox",value:"{\\\\"checked\\\\": ' + permutation + '}"){id}}'
Logger.log('-----------------------------')
Logger.log("Testing query with: " + JSON.stringify(permutation));
runQuery(query);
let result = runQuery(queryCheckboxState);
getCheckedStateFromResult(result)
}
which then runs the query via the method below:
function runQuery(query) {
var result = UrlFetchApp.fetch("https://api.monday.com/v2", {
method: 'post',
headers: {
'Content-Type': 'application/json',
'Authorization': MONDAY_KEY
},
payload: JSON.stringify({
'query': query
})
})
return result;
}
}
then the output of the iterative execution is:
7:37:29 AM Info Started: Tue Sep 13 2022 07:37:29 GMT-0700 (Pacific Daylight Time)
7:37:29 AM Info Checking baseline checkbox state
7:37:29 AM Info null
7:37:29 AM Info -------
7:37:29 AM Info -----------------------------
7:37:29 AM Info Testing query with: "\\\\\\"true\\\\\\""
7:37:30 AM Info {"checked":"true","changed_at":"2022-09-13T14:37:29.801Z"}
7:37:30 AM Info -----------------------------
7:37:30 AM Info Testing query with: null
7:37:31 AM Info {"checked":"true","changed_at":"2022-09-13T14:37:29.801Z"}
7:37:31 AM Info -----------------------------
7:37:31 AM Info Testing query with: false
7:37:31 AM Info {"checked":"true","changed_at":"2022-09-13T14:37:29.801Z"}
7:37:31 AM Info -----------------------------
7:37:31 AM Info Testing query with: "false"
7:37:32 AM Info {"checked":"true","changed_at":"2022-09-13T14:37:29.801Z"}
and so on for the other fails.
It was @ MelissaH who got me partially unstuck via this post; THANKS: Mutating a Date in v2
I’d be very grateful if it might be possible to comment on how, in Google Apps Script to pass in null
to uncheck a box?
Thanks in advance 🙂
Julie,
it’s been several years since I tried to uncheck a box, but here’s how I typically write my Monday API queries:
- Tweak the query in the API playground until I get it working there - usually the documentation leaves things out and a raw copy/paste involves some tweaking to get confirmation
- Switch to Postman and tweak it again until the JavaScript works the same way the original query did - as you found, there are quirks to the way the Monday API interprets backslashes and quotation marks.
- Once I have a working JavaScript query in Postman, it’s usually a pretty simple copy/paste to GAS.
Hello @McMurry!
Please note that the mutation you are using is change_column_values
and what I sent is change_multiple_column_values
.
Also, at least on the GraphQL side, you are using two backslashes to escape outer quotes when only one is needed (not sure if you are using 2 because of some GAS syntax requirement). And no quotes are needed for null
:
column_values: "{\\"checkbox\\" : null}"
Regarding the syntax required in GAS, I am sorry I can not help there since I have no experience with it.
Cheers,
Matias
Thanks, when I get back to this project, I will certainly try. I appreciate your willingness to respond.
Matias,
GAS syntax for API requests is diabolical and ever-changing. consider yourself lucky to have no experience in it 😃
Well hey, at least in GAS API, I’ve never seen “null” and “true” being required opposites of each other 😉