Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Duplicate Form responses to two Google Sheets programmatically

I need to save my Google Form in two different sheets.

The first sheet will be the one for history and the other one will be exploited by the logistic services (who may delete some rows when the clients receive the shipped stuff).

I really need to keep all the responses on the first sheet whatever the logistic services do on the second.

The fact is; I was using formRat, but is not working anymore and I don't see any complementary module that does exactly the same thing. I'm not good enough in programming to write the script by myself.

I tried to write this in the second sheet:

=ArrayFormula('first_sheet_name'!A:W)

But when I try to delete a row on the second sheet, it reappears a few seconds later because Google Sheets recalculates it.

like image 577
Pierrick Marchand Avatar asked Oct 21 '15 12:10

Pierrick Marchand


People also ask

How do I duplicate Google form responses?

Just click the 3-dot button on the top right corner of your Google Form, and select Copy. You can then give the copy of the new form a different name, and tweak anything you want.

Can Google form responses go to multiple sheets?

Note: You can store results from multiple forms in one spreadsheet; each form's responses will be saved to a separate sheet. You cannot, however, save multiple forms' responses to a single sheet.

How do you duplicate multiple Google Sheets?

Usually, to duplicate several sheets, you press the Ctrl key and hold it while selecting each required sheet.

How to prevent duplicates in a Google Sheet when submitting a form?

This code prevents duplicates in a Google Sheet when submitting a Google Form, by overwriting an existing row with the existing unique value, if one exists. The code searches one column in a spreadsheet and looks for a match.

Why am I getting duplicate form responses on Google Forms?

Many users simply click the button to resubmit form data, this in turn causes a duplicate response. The solution to the problem is actually quite simple, but can only happen from Google's side of things.

Can I copy form responses from one Google Sheet to another?

This works fine in my master copy. However, when a colleague makes a copy of the form, they have to specify which Google Sheet to use for responses. They select the copied Google Sheet, but then a new worksheet is inserted into that Google Sheet, called "Form Responses 2".

What are some key words for duplicates?

Key words: duplicates, Google, spreadsheet, Sheets, Form, submission, edit, row, unique. This code prevents duplicates in a Google Sheet when submitting a Google Form, by overwriting an existing row with the existing unique value, if one exists. The code searches one column in a spreadsheet and looks for a match.


1 Answers

A form submission trigger script attached to the Form Response spreadsheet can easily copy responses to the second sheet, as they arrive. Any modifications made later on the second sheet will survive.

Here is a very simple example of such an Installable Trigger Function. You need to declare ss2ID with the Sheet ID of spreadsheet 2. The script assumes that the responses are to be copied to the first sheet in spreadsheet 2, and that all form answers are populated.

function copyResponse( event ) {
  fixFormEvent( event );  // From https://stackoverflow.com/a/26975968/1677912
  var ss2Id = "---sheet-id---";
  var sheet2 = SpreadsheetApp.openById( secondSheetId ).getSheets()[0];
  sheet2.appendRow( [event.values] );
}

This function uses fixFormEvent( event ) from e.values in google forms skips empty answers, is there a workaround? to ensure the columns in the new sheet align with the original questions.

like image 123
Mogsdad Avatar answered Nov 15 '22 08:11

Mogsdad