问题
As a way of initializing a form record, I want to fill and submit a google form with apps script. The key bit of documentation for form.createResponse() is this
Creates a new response to the form. To answer a question item, create an ItemResponse from the item, then attach it to this form response by calling FormResponse.withItemResponse(response). To save the assembled response, call FormResponse.submit().
do I need to new FormResponse() or how do I make this happen?
回答1:
create new form
var test_form = FormApp.create('test1');
test_form.addTextItem();
get the first question as a text item
var questions = test_form.getItems();
var qt = questions[0].asTextItem();
set the response
var qr = qt.createResponse('cats');
create and submit a response object
var FormResponse = test_form.createResponse();
FormResponse.withItemResponse( qr );
FormResponse.submit();
来源:https://stackoverflow.com/questions/36831901/how-to-create-a-google-form-response-with-app-script