Skip to main content

Changing multiple column values with one mutation

  • December 2, 2022
  • 10 replies
  • 1796 views

  • Participating Frequently

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?

10 replies

Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 5, 2022

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 🙂

Cheers,
Matias


  • Author
  • Participating Frequently
  • December 6, 2022

Hello @Matias.Monday,

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

Regards,

Onur


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 7, 2022

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


  • Author
  • Participating Frequently
  • December 7, 2022

@Matias.Monday,

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


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 8, 2022

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


  • Author
  • Participating Frequently
  • December 10, 2022

@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?


  • Participating Frequently
  • December 10, 2022

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/


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 11, 2022

Hello again @Onur!

Any tutorial like the ones @anon29275264 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 @anon29275264!!

Cheers,
Matias


  • Author
  • Participating Frequently
  • December 13, 2022

@anon29275264 @Matias.Monday,

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

Regards,

Onur


Matias.Monday
Forum|alt.badge.img
  • monday.com Team Member
  • December 14, 2022

Sounds good 🙂

Let us know if you need anything!