Increment a single column for all items using another column

I’m using a board to track clients balances. I already have it working to where some transaction will deduct the total cost from a specific clients/items balance. However, I’m trying to write a mutation that will increment all clients balances by an amount determined in another column.

The schema looks something like this:
Screen Shot 2021-08-11 at 11.25.23 AM

I thought that maybe I could just create a giant mutation containing a change_simple_column_value and create_update for each client dynamically, but the mutation query only seems to allow for a single change_simple_column_value at a time.

Field 'change_simple_column_value' has an argument conflict: {board_id:"X",item_id:"Y",column_id:"\"numbers\"",value:"\"37\""} or {board_id:"X",item_id:"Z",column_id:"\"numbers\"",value:"\"66\""}

Of course, I could just send a discrete mutation per client, but that’s bound to hit some rate limit and just seems like a rather obtuse way to perform this action.

Hi @SugarmanZ,

At this time it sounds like the change_multiple_column_values method would work better for you. The only difference is you need to send your column values as JSON rather than simple strings.

Here is the section in our API documentation that explains this method: https://api.developer.monday.com/docs/change-column-values#changing-multiple-column-values.

However, I’m wondering if perhaps a Formula column wouldn’t work better for you instead? You can even use the General Caster app to “cast” the formula results back into the same column.

Here is the app in our marketplace: https://monday.com/marketplace/8.

Hello @Helen,

Thanks for the info. Though, I’m not sure the change_mutliple_column_values is the correct approach either. From the docs:

This mutation allows you to update multiple column values of a specific Item (row).

I want to update a single column for multiple items with one call.

I don’t think the Formula column works either because I need this to be discrete event that happens once every month. It’s not a concurrent calculation being run all the time. I need to be able to increment each items current balance with their monthly allowance the first of every month.

Hi @SugarmanZ,

Got it-- thanks for clarifying this.

Yes if you’re looking to update a single column for multiple items, I’m afraid the best way to do this would be to query all of your item IDs on your board, and then assign them using a dynamic variable with a single change_simple_column_value mutation to change their column value.

This would be your best bet!

@Helen,

Yes, this seems promising. Do you have any documentation or suggestions on how to create such a query with a dynamic variable? The only documentation I found on variables led me to create this:

mutation update_client_credits($clientId:Int!, $balance:JSON!) {
    change_simple_column_value (board_id: X,item_id: $clientId column_id: "numbers", value: $balance) {
        id
    		column_values {
          title
          text
        }
    }
}
{
  "clientId": 1111111111,
  "balance": "1300"
}

But as you probably guessed, this doesn’t help me with updating all items at once. I couldn’t find much information about iterating mutations over some JSON list. Server side, I already have a JSON payload containing all the client IDs and updated balances. I just need the mutation query to set them.

Hi @SugarmanZ,

Ahh okay I see. Yeah we don’t currently offer a way to dynamically pass variables within our API. You would need to complete this step in your server-side code.

So in this case you would most likely need to write a for-loop or an if statement that would pass each of these items into this mutation.

Hello @SugarmanZ,

@Helen is correct. There are currently no API features that allow for bulk item updates. All updates would need to be done on a per-item basis.

With that said, @Helen, are there any plans to add in a bulk item update feature for the API? That would be most stupendous if so, as we do bulk item updates for some of our internal processes. Having an option to bulkify this would improve performance tremendously for us. :grin:

Thank you both for your time, and I wish you all the best.

Andrew

Hi @andrew.shatz,

It’s in the books! Sadly there aren’t plans in the coming months for this feature to be released.

However, I’m happy to forward your feedback for our team to continue prioritizing it.

Thank you for your feedback!! Keep it coming!