Changing multiple column values with one mutation

Hello,

I am looking for a way to change the column values for multiple items using the same mutation. I use change_column_value to do this for one item at a time, but the number of items I have on my board make this process inefficient. How can this process be done iteratively? If possible, where can I find an example of it?

Hello there @Onur!

You can use an iteration in your script to go through your items.

You can also send multiple mutation inside the same request like this:

mutation {
  changeItem1: change_simple_column_value(board_id: 1234567890, item_id: 1111122222, column_id: "text", value: "Hello 1") {
    id
    name
  }
  changeItem2: change_simple_column_value(board_id: 1234567890, item_id: 2222211111, column_id: "text", value: "Hello 2") {
    id
    name
  }
}

I hope that helps :slightly_smiling_face:

Cheers,
Matias

Hello @Matias.Monday,

Thank you for the reply. Would you be able to give an example of the iterative script you mentioned?

Regards,

Onur

Hello @Onur,

Yes, you can use any language you want to create a simple iteration. Here is a classic for iteration using JS as a basic example:

  myFunction () {
    for (let i = 0; i < usersList.length; i++) {
      monday.api(`mutation {create_notification(text: "This is my text", user_id: ${usersList[i]}, target_id: 1234567890, target_type: Project) { id }}`);
    }
  }

I hope that helps!

Cheers,
Matias

@Matias.Monday,

Since the API playground only supports scripts written in GraphQL, what platform can I use to write this script using JavaScript?

Hello again @Onur,

We do not have recommendations on where to write or host developers scripts. We usually write our code in Visual Studio Code if it is helpful as a reference. For testing, I usually use the terminal in visual studio code, run a file using Node and expose to the internet using ngrok. Again, these are not recommendations, just some references.

Cheers,
Matias

@Matias.Monday,

I appreciate the references. I currently do not possess much knowledge on using Node. Where can I learn the steps I need to take to make use of this script? Can you direct me to someone or any particular source?

Here is an example I found for learning JS on youtube, which has a lot of free content that can help out.

You can go to node.js to get Node.js. You can write your code in https://code.visualstudio.com/

1 Like

Hello again @Onur!

Any tutorial like the ones @codyfrisch sent, can be good starting points. There are many of them for free online on Youtube. There are also usually various courses on platforms like Udemy or Platzi if you would rather use those. Again, these are not recommendations, but rather some references for you to have.

Thank you @codyfrisch!!

Cheers,
Matias

@codyfrisch @Matias.Monday,

Thanks for the suggestions. I will reach out again if I have more questions.

Regards,

Onur

1 Like

Sounds good :slightly_smiling_face:

Let us know if you need anything!