How do I increment a counter in a cell of a Google sheet?

This topic was automatically generated from Slack. You can find the original thread here.

Konstantin Valter : Hello everyone. Does’ anybody know how to do simple webhook: When i click weblink then update value in my google sheets +1
I can’t find any information how to add this “counter” :disappointed:

Dylan Sather (Pipedream) : take a look at our docs on workflow state - we’ve got an example for how to increment a counter there.

This example workflow should help you get started. Let me know if you have any questions about that!

Konstantin Valter : Thanks a lot for the answer!) It’s almost what i need. But i need to UPDATE value, not add new row.
I tried to do it myself but i got ERROR 400 :disappointed:
I took this sample action “Update Spreadsheet Values” and it is with error. My code is here: https://pipedream.com/@konstantinvalter/increment-counter-and-update-value-p_ZJCbVVz

What i do wrong?(

Dylan Sather (Pipedream) : you’ll see a blue Share button near the top-right of your workflow. Can you click that and share your workflow with dylan@pipedream.com?

Dylan Sather (Pipedream) : That way I can see the error you’re seeing

Konstantin Valter : I made public access https://pipedream.com/@konstantinvalter/increment-counter-and-update-value-p_ZJCbVVz

Konstantin Valter : And gave you Edit access

Konstantin Valter : dylan@pipedream.com

Dylan Sather (Pipedream) : a couple of issues I observed:

  1. Just to confirm, do you only want to update a single cell with the new value of the counter? You had Sheet1!A1:B2 as the value of the range to update, but that means Google will attempt to update 4 cells: the grid that contains A1, A2, B1, and B2. See the Google Sheets docs for more info. If you want to update a single cell (for example, A1, just add Sheet1!A1:A1).
  2. The Values parameter expects an array of arrays (essentially, the row and column data you’d like to update). I updated the example workflow to show you how to format that data in the way Google expects. Essentially, you’ll want {{ [steps.increment_counter.checkpoint ] }} in that field.
    Take a look at the example workflow and let me know if that helps.