Appending or updating row in Google Sheets

Describe the problem/error/question

Just learning, so new to this.
When a gmail arrives I use an edit node to get the text I want and add it to a google sheet.
I have a unique number (called Fix Number) and if that Fix Number is the same I would like to overwrite that row. If the Fix Number is different then it should create another row (append). What I am finding is that every time I test with the same Fix number I get another row, I was hoping just to see one entry in the sheet.

Please share your workflow

This is the entry in Google Sheets

Information on your n8n setup

I’m using the trial version from the cloud, installed 5 days ago, not sure what version number it is - sorry.

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Did you add this two line both by the email ? I just wanna make sure that they are the same, maybe there are something different in data type.

Hi - they are both by email.
I’ve just sent another with the same unique Key, my thinking is that I have a unique key so the row would just be replaced instead I have another entry/row. Or is my understanding on Append or update row wrong?


Thanks

Sometimes you need to match the value type.

If you are trying to compare a number to a string, this might be an issue, sometimes.

Try using .toNumber() or .toString()

Let us now how it goes!

:muscle: If my reply solves your problem, please remember to mark it as a solution.

Your code definitely handles all inputs as text, while from data formatting in column A Google Sheet treats stored data as numbers. So server side it may indeed compare text (sent by you) with a number (stored in the sprreadsheet), just as @solomon suggested. If .toNumber() doesn’t work for you, then maybe try changing the formatting on spreadsheet side by setting the Column A format explictly as plain text.

Upd: Make sure you do not have any whitespaces before {{ or after }} in your expression. I was able to reproduce the behaviour you observe by adding a whitespace outside the expression brackets.

Upd: Here you go. You’ve got one in the Edit Fields node.

A very subtle bug to catch!

2 Likes

From what I can see in Olek’s screenshots, .toNumber() will fix it for you, as I first suggested.

Thank you @solomon and @Olek - I made your suggestions and it has fixed the issue. I was not scientific in my testing so do not know if one or all the solutions provided did the job. Many thanks.
As I’m new here and you suggest to “mark it as a solution”, I’m assuming this is for some type of recognition (which is well deserved :slight_smile: ). Is it possible to tick both as solutions?

2 Likes

Unfortunately no. Just pick the one you think helped you the most.

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