Update Google Sheets Rows, dynamically picking column (different columns each time)

Hi folks,

I have a code node that always provides me (1) an ID and (2) a Field to be updated (containing the new value in it). I want to be able to Update Row on a Google Sheets table, but in different columns each time (named exactly as my 2nd input field).

Thus, I cannot just paste the value on columns (as screenshot below), because next time it will be a different column that needs to be updated… I’ve tried automatic mapping, but it crashed my Sheets (and removed all my Array Formulas in it, replacing them by values).

Any advice?

here is how I updated values:

code node gives 5 objects 1; id, 2; value

all are updated in sheet

Here is an alternative:

Original table:

ID COL1 COL2 COL3 COL4 COL5
id-1 1 2 3 4 5
id-2 10 20 30 40 50
id-3 100 200 300 400 500
id-4 1000 2000 3000 4000 5000
id-5 10000 20000 30000 40000 50000

with new value for row id-5 and column COL4 set to 11111 in the Set node, the table becomes:

ID COL1 COL2 COL3 COL4 COL5
id-1 1 2 3 4 5
id-2 10 20 30 40 50
id-3 100 200 300 400 500
id-4 1000 2000 3000 4000 5000
id-5 10000 20000 30000 11111 50000
1 Like

I was thinking of making a sub-workflow that only contains the JSON of the Google Sheet “Update Row” node, and then using expressions to match the predefined dynamic columns.

But the solution from @jabbson is simpler and better. I just learned that it’s possible to do it that way using that hint.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.