如何使用应用程序脚本创建Google表单响应 [英] how to create a google form response with app script

查看:52
本文介绍了如何使用应用程序脚本创建Google表单响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为初始化表单记录的一种方法,我想用Apps脚本填写并提交Google表单.form.createResponse()文档的关键是这个

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

创建对表单的新响应.要回答问题,请创建来自项目的ItemResponse,然后通过以下方式将其附加到此表单响应中调用FormResponse.withItemResponse(response).保存组装好的响应,请调用FormResponse.submit().

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().

我需要新的FormResponse()还是如何做到这一点?

do I need to new FormResponse() or how do I make this happen?

推荐答案

创建新表单

    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();

设置响应

    var qr = qt.createResponse('cats');

创建并提交响应对象

    var FormResponse = test_form.createResponse();
    FormResponse.withItemResponse( qr );
    FormResponse.submit();

这篇关于如何使用应用程序脚本创建Google表单响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆