Reputation: 77
I create a Google Spreadsheet and a Google Form via the Google App Script and want to get all the responses from the form automatically added to a sheet in my spreadsheet.
This option is possible if you do it manually, but I can't find an option to do it automatically in Google App Script.
I have seen some answers here on StackOverflow to populate forms from spreadsheets, but I need the inverse case.
Is that possible?
Upvotes: 1
Views: 2136
Reputation: 15328
Google Forms has a setting that allows you to send your form responses to Google Sheets. This can be a new or existing spreadsheet.
In your chosen form, click on the responses tab.
If you want to do it by script, as the form is already created
var form = FormApp.openById('id of the form');
form.setDestination(FormApp.DestinationType.SPREADSHEET, 'id of the spreadsheet);
Upvotes: 1
Reputation: 19220
Use Form.setDestination(), like this:
const ss = SpreadsheetApp.create('Response destination spreadsheet');
const form = FormApp
.create('New form name')
.setDestination(FormApp.DestinationType.SPREADSHEET, ss.getId());
Upvotes: 2