Column mutation sending checked = false still checks checkbox

Hi! I’m trying to update a checkbox column but if I send the checked value as false it still checks the column:

mutation {
 change_multiple_column_values(item_id:295524638,board_id:287994487,column_values:
  "{\"check\": {\"checked\": \"false\"}}"){
    id
 }
}

Any advice?

Argh, missed this part: https://monday.com/developers/v2#column-values-section-removing-values

Need to unset instead of sending false.

1 Like

Hi @werner,

For me, it is not working…I tried to unset by sending “empty string and empty object” as well it did not work…Can you help on how to do that…

mutation{change_multiple_column_values (board_id:xxx,item_id:xxx,column_values:"{\"check\":{\"checked\":\"\"}}") {id}}

mutation{change_multiple_column_values (board_id:xxx,item_id:xxx,column_values:"{\"check\":{\"checked\":\"{}\"}}") {id}}

@upitchika Can you please have a look at it too…

Thanks

Hey @krishna :wave:

Thanks for bumping this topic instead of creating a new one! That’s awesome community-skills right there :slight_smile:

As for the issue you are having, I’ve just tried to change a single column value of the check column using the following query and that seems to have worked for me:

mutation {
change_column_value (item_id: xxxxxxxx, board_id: xxxxxxxx, column_id: “check”, value: “{}” ) {
id
}

Would that work for you in your workflow? Let me know!

-Alex

2 Likes

Hey @AlexSavchuk

Thanks for the response,but in my case, I need to update multiple column values at once…
that is the reason i used change_multiple_column_values mutation.

Can you suggest how to unset the checkbox field using this mutation?

1 Like

@krishna

Got it, and that makes total sense! I’ll get back to you here as soon as I have a working example of the code here. I am about to head out for the day though, so it might take me a bit longer to respond here :slight_smile:

-Alex

Sure @AlexSavchuk :slightly_smiling_face:

Hey @krishna

This is another gap in the documentation, apparently the right way to remove a column value for a boolean column is to pass a null

mutation {
change_multiple_column_values (item_id: 720816500, board_id: 720816496, column_values: "{\"check\":null}") {
  id
}
}

I queried an existing empty checkbox column and got this in return

"column_values": [
          {
            "id": "check",
            "value": null
          }
        ]

I sent the same value in the mutation to clear the checkbox column.

Please try it and let me know if that works.

@AlexSavchuk - another improvement in the API docs.

Thank you !!

Edit :- I though this is a gap in documentation but seems like it’s an inconsistency issue with the API itself.

When I pass null to mutate a single column using change_column_value, I’m getting this error message
"message": "Argument 'value' on Field 'change_column_value' has an invalid value. Expected type 'JSON!'.",
The right way in that case is to pass an empty JSON as @AlexSavchuk suggested.

However, to mutate multiple columns, sending empty JSON doesn’t work.

I tested with “Text” column and observed the same behavior. @AlexSavchuk - this may be true for even more column types.

TLDR -
For change_column_value mutation, use an empty JSON to clear out column values.
For change_multiple_column_values if using an empty JSON doesn’t work, try using a null.

1 Like

Hey @krishna

You can uncheck a checkbox in GraphQL like this:

mutation {
   change_multiple_column_values (board_id: xxx, item_id: xxx, column_values: "{\"check\": {}}") {
id }}

In code, you’ll need to use variables:

const query = `mutation change_multiple_column_values($column_values: JSON!) {
        change_multiple_column_values (board_id: xxx, item_id: xxx, column_values: $column_values) {id}}`

await monday.api(query, {variables: {"column_values": 
   JSON.stringify({check: {}})}
})

You can read more about variables here:

https://monday.com/developers/v2#using-grpahql-section-variables

Hope this helps!

2 Likes

Thanks, @supernova :slightly_smiling_face: I am using Monday dev tool for testing. I will let you know once I work on the code.

Hi @upitchika,

Thanks for the response it worked for me :slightly_smiling_face:.However these inconsistencies and documentation issues should be handled as it makes things complex.

@AlexSavchuk Please forward to the respected team and update the documentation.

Thanks

2 Likes

Hey @upitchika and @supernova - thanks for your awesome suggestions here! That null workaround is quite cool, and using variables as :whale2: pointed out is what we suggest in all cases to make your life just a little bit easier.

That said, I really appreciate your insight and troubleshooting here - I’ve already gone ahead and added your notes and feedback about the way this works, as well as the way it’s presented in the documentation to our team. Thank you for helping us improve!

-Alex