Last Updated:

How to Distribute Google Form Responses to Multiple Spreadsheets

Ahsan
Ahsan google form

Google Forms is one of the most popular tools for collecting online data. Its seamless integration with other Google apps, especially Google Sheets, makes it a standout choice among form builders.

By default, each form you create links to just one Google Sheet. However, challenges arise when you need to share form responses with multiple people without granting access to the primary spreadsheet.

This situation is common in workplaces, where multiple divisions might need to access the same form but require separate spreadsheets. Sharing separate sheets ensures data accuracy and restricts access to sensitive information in the main spreadsheet.

If you’re looking to set up a form that distributes responses to multiple spreadsheets, here’s an enthusiastic, step-by-step guide:

1. Add the Script Editor

Click the three-dot menu in the top-right corner of your form, then select "Script Editor".

Editor Skrip Google Form

2. Insert the Following Code

Once the Script Editor opens, paste this code:

function onFormSubmit(e) {
  const itemResponses = e.response.getItemResponses();
  var responses = e.response.getItemResponses(); // Get the submitted responses
  
  // Construct an array of response values
  var formResponse = responses.map(function(response) {
    return response.getResponse();
  });

  // Get the timestamp of the form submission
  var timestamp = e.response.getTimestamp();
  
  // Add timestamp to the beginning of the formResponse array
  formResponse.unshift(timestamp);
  
  const pertanyaan_kedua = itemResponses[1].getResponse();
  // var main_spreadsheet = SpreadsheetApp.openById('SPREADSHEETID');
  // var main_sheet = main_spreadsheet.getActiveSheet();
  var second_spreadsheet = SpreadsheetApp.openById('SPREADSHEETID');
  var second_sheet = second_spreadsheet.getActiveSheet();

  if (pertanyaan_kedua === 'Opsi 1') {
    second_sheet.appendRow(formResponse);
  }
  // else {
  //   main_sheet.appendRow(formResponse);
  // }
}

Step 3: Create a New Spreadsheet and Share Access

Create a separate Google Spreadsheet and ensure the necessary team members have Editor access.

Berbagai Akses Spreadsheet

Step 4: Update the Spreadsheet ID in the Code

To find your spreadsheet’s ID, open it and copy the part of the URL between /d/ and /edit.

Cara Identifikasi ID Spreadsheet

Step 5: Set Up a Trigger

Next, configure a trigger to determine when the script will run. This step ensures your script executes every time a new form submission is received.

Mengatur Trigger Google Script

Step 6: Adjust the Trigger Settings

Customize the trigger to match your needs, such as running the script on every form submission.

Atur Trigger Google Form Script

Step 7: Test the Setup

Now for the fun part—testing! Fill out and submit your form. Then, check the linked spreadsheets to confirm that the responses are correctly distributed.

That’s It!

And there you have it—a simple way to distribute Google Form responses to multiple spreadsheets. This setup is perfect for collaborative environments, ensuring data is shared efficiently while maintaining control over sensitive information.

Good luck, and happy form building!

Ahsan

Ahsan

Halo, perkenalkan, saya Saad Ahyat Hasan. Ahsan itu akronim nama tengah dan belakang saya, Ahyat Hasan. 

Sehari-hari bekerja sebagai programmer, freelancer, dan pembuat konten.

Melalui blog bloggertekno ini saya ingin berbagi semua hal menarik yang saya dapatkan dari internet. Untuk kembali saya bagikan kepada lebih banyak orang. Agar semakin banyak orang yang mendapatkan manfaat yang sama.

Kalau ada tawaran pekerjaan, kerjasama, undangan, atau apapun yang masih ada hubungannya dengan saya, saya pastikan kotak email saya (kamuitubeda[at]gmail.com) selalu terbuka.