Update multiple column values using mutation

Hi,

I am trying update multiple column values of an item using mutation,But I am getting error code 500 everytime.

Can anyone please help me out ??

Sending the data into column values in the following format.

{“person3”:“Person one”,“numbers”:22,“location”:“New Delhi”,“date”:“IDBI Bank”,“numbers8”:500}const updateItem = async (token, boardId, itemId, columnvalues) => {
debugger
try {
const mondayClient = initMondayClient({ token });

const query = `mutation change_multiple_column_values($boardId: Int!, $itemId: Int!, $columnvalues: JSON!) {
  change_multiple_column_values(board_id: $boardId, item_id: $itemId, column_values: $columnvalues) {
      id
    }
  }
  `;
const variables = { boardId, itemId, columnvalues };

const response = await mondayClient.api(query, { variables });
console.log(response)
return response;

} catch (err) {
debugger
console.error(err);
}
};

Attaching the snaps of my code.

@kolaai @Helen @basdebruin
Can you please help me out for this issue?

Even I am unable to stringify the data in the said format.I have successfully updated the data from playground but when I simply copy that data to my code,Then also its not working.
JSON.stringify() is also not giving me the desired result.

Getting Internal Server Error all the time.

Attaching one more screenshot.

Hey @aquibk

I’m sorry to hear you are having issues updating multiple columns of an item within a single mutation call! I’d be glad to investigate this further with you.

Just to make sure we’re on the same page here, are you using a User ID in the People column value you are sending? Also, when you send location column data, are you using the correct value format? Currently, the Location column expected latitude and longitude coordinates, and adding an address like New Delhi is optional and will simply act as the display text. You can find out more about the value format for this column below:

Updating Location column - API docs

Otherwise, it would be great to see a mutation that works within the Playground with the full values you are looking to apply to the item, and what you are sending within your application instead with variables. This will help us troubleshoot the behavior further.

I’m looking forward to hearing from you soon! :slight_smile:

-Alex

JHi @AlexSavchuk ,

Thanks for the response, As far as the people column is concerned here is not of the type people but text as I am just trying my hands with the mutation of multiple column values at the same time.
Whereas,For location column I am sending the text value like “New Delhi” which i can ignore also for now as my problem is that I am unable to stringfy in this format {“person3”:“Person one”,“numbers”:22,“location”:“New Delhi”,“date”:“IDBI Bank”,“numbers8”:500} as you can refer my screenshots even when i directly put the same above string to a variable,It gets changed to something like this … ‘{“person3”:“Person one”,“numbers8”:“20”}’.

I have tried almost all the ways to stringify it with the help of JSON.stringify().

And my quiestion is also that can’t we mutate the data with this format ‘{“person3”:“Person one”,“numbers8”:“20”}’ ???

Attaching one more screenshots where i am trying to mutate only two column values and those are of type text and number where I am getting the same Internal Server Error of code 500.

Hello @aquibk,
I believe you might be sending the wrong format to update the columns. Every column a specific format that it receives. For example, if the date argument is being used to update a date column, sending IDBI Bank will definitely result in an error.
For example, if you want to update a date column, the data you send to monday.com must look like something like this:

const data = {
  date: {date: "1993-08-27"},
  numbers8: "20"
};

const jsonFormat = JSON.stringify(data);

console.log(jsonFormat);  // "{\"date\":{\"date\":\"2020-08-28\"},\"numbers8\":\"20\"}"

The first date is the column id
The logged format is what you can now send to monday.com to update your columns.


Check the respective format required to update the columns in the docs.

Hi @kolaai ,

In the above screenshots, You can see that for now, I am just trying to send two fields (text and number).
And doing the same what’s been suggested (creating an object and strigify it with the help of JSON.stringify()) but still I am unable to get the desired format.

Please consider the above screenshots.

Thanks…!!

Hey Aquib, I understand we’ve got an email thread with you. Let’s communicate on that thread, and we’ll update here once we’ve helped you fix your code!

Hi guys I’m also struggling to update multiple column values in the play ground, to be specific it seems like it doesn’t like column type text.

I’m new in this I’d appreciate it if you can help me out. Thanks

Hello @Siyabonga,
If you are sending a text of “DUT” to a column of column id of client4, then your query has to be

\"client4\":\"DUT\"

instead of

\"client4\":{\"text\": \"DUT\"}

Hello @kolaai,

Thank you, It’s working.