Google sheet appended same row multiple times

Hello all

So I’ve created a workflow where a webhook is called whenever an user registers at a forum and those details from the signup form are used to generate a unique ID number based on certain characteristics, like the college they study at.

The problem here is, when a single person uses the website and registers at a time, there is no problem but when multiple people from same college signup at the same time (which is what normally happens) one of the rows get added twice or thrice resulting in duplication of that record in GSheets.

Also, my workflow is as follows:

Data from webhook> decoded JWT token, with the information of the person > relevant GSheet is retrieved from google drive using the node for it> the Gsheet is checked for any existing records for the same person to prevent duplication> if not, then proceeds to add the details to the relevant GSheet

If the record is already present, then data isn’t added to the GSheet, instead I get a Telegram notification saying that duplicate registration has occurred in the forum.

When multiple users sign up for the forum from the same college, the webhook is called at the same time with different data due to which it adds same record 2 or 3 times

I tried using the time delay node to add 3 seconds delay but still this problem doesn’t stop

Kindly help

Check your executions and view the data that is coming into the webhook. You may find the incoming data is duplicated due to a layer inbetween. It could be the browser or user is retrying the webhook if it times out, for example. It could even be user behaviour, double-clicking the submit button. This could especially be the case if your EXECUTIONS_PROCESS is set to main, as only one workflow would run at a time.

If this isn’t the case, follow the data through until you find whether the items are being duplicated inside the workflow.

1 Like

I think it’s due to duplication on user end. How do I prevent that?

I checked, and the data isn’t duplicated at forum’s end but only on N8Ns end.
How do I prevent this?

Have you checked your EXECUTIONS_PROCESS value? If you’re using a webhook or similar from the forum’s end, it may be retrying the call.

What does your n8n executions show? If it’s receiving multiple calls to the webhook, n8n is just doing as it’s told.

Past that it’s a architecture problem that you may need to review your solution and look at building something to filter your data.

I have found a way to tackle this.
I can use GDrive trigger node and find the file thats last updated, and then check that file for duplicates and just remove that row…
But now I dont know how to build a workflow to find duplicates alone

1 Like

It sounds like you’re making this hard for yourself trying to use a Sheet as a database.

You might want to look at using something like Airtable instead of Sheets, or an actual database like MySQL.

Umm there are 100s of similar Gsheets that we manage so GSheets are better for our use case tbh

Actually the webhook is being called Multiple times. the users retry by mistake and then it duplicates the data by recalling the webhook

Then, on the form, you should probably disable the Submit button after clicking and provide some feedback to say it is being submitted.

Another alternative is to generate a ‘token’ in the form as a hidden input field which you can track and only allow submission once.

You may also want to split out the receiving and the processing; have the webhook quickly store the submission, then process it later with a different workflow.