谷歌脚本 - 整个表单删除

时间:2015-06-30 20:25:52

标签: javascript forms

我想通过电子邮件将表单发送给15个用户。表单只包含两个问题,一个带有预设长码的径向按钮,另一个是是和否。因此,在Google Script中创建表单并通过电子邮件发送表单不是问题。

但是,一旦用户提交,我希望删除此表单。我知道我可以将isAcceptingResponses()做为假,并让这些旧表格在我的Google云端硬盘中消失。但是,如果我这样做,我会继续在Google云端硬盘中收集不相关的表单。无论如何要破坏一个表格?或者你会建议什么?

以下是根据Google开发人员手册创建表单的示例 https://developers.google.com/apps-script/reference/forms/

function myCreateForm() {
var form = FormApp.create('Form Autocreaticus');
var item = form.addCheckboxItem();
item.setTitle('What condiments would you like on your hot dog?');
item.setChoices([
        item.createChoice('Ketchup'),
        item.createChoice('Mustard'),
        item.createChoice('Relish')
    ]);
form.addMultipleChoiceItem()
    .setTitle('Do you prefer cats or dogs?')
    .setChoiceValues(['Cats','Dogs'])
    .showOtherOption(true);
form.addGridItem()
    .setTitle('Rate your interests')
    .setRows(['Cars', 'Computers', 'Celebrities'])
    .setColumns(['Boring', 'So-so', 'Interesting']);

Logger.log('Editor URL: ' + form.getId());

 return form.getId()  //so I can later use for my myDeleteForm().
}


    function myDeleteForm() {    //myDeleteForm(formID) {
  var formID = '1utQdu9EsuQFgMKNbP5Hjm68fxpP-_vKrBNNXL8jsOZo';
  DriveApp.getFileById(formID).setTrashed(true);
}

*此代码已更改以适应功能。谢谢!

1 个答案:

答案 0 :(得分:3)

要删除文件本身,您可能需要使用DriveApp。您找到的方法似乎只是删除/更改设置或响应。

删除:

function myDeleteForm() {    
    var formID = '1utQdu9EsuQFgMKNbP5Hjm68fxpP-_vKrBNNXL8jsOZo';
    DriveApp.getFileById(formID).setTrashed(true);
}
相关问题