Edit Form Responses as soon as it is submitted

懵懂的女人 提交于 2019-12-01 13:12:57

A Form response inside of a Google Form can NOT be edited with Apps Script. A response saved to a spreadsheet can be changed, but an existing response in a Form can not be changed. A Form response can be deleted with code, but not edited with any Apps Script methods.

You can manually set up an On Form Submit trigger. There is no need to create a trigger from code unless you are doing something like creating new Forms with code, and distributing them automatically. Or having people install an Add-on to the Form.

Form responses are always written into the Form. You can also set a spreadsheet as the response destination. In that case, the Form answers will be saved to both the Form and a spreadsheet. You can not intercept the data before it's written into the Form. But you can change it immediately after it's written.

The function that serves as the On Form Submit trigger can receive a JavaScript object with Form data. The variable name used for the event object is often the letter "e", because the letter "e" is the first character in the word "Event." But the variable name can can be anything.

function myOnFormSubmitFunc(e) {};

An On Form Submit trigger can be either in the Form, the Sheet, or both. The On Form Submit object for the Sheet is different than for the Form. For example, with the Sheet On Form Submit object, you can directly get an array of values.

var arrayOfValues = e.values;

Apps Script Documentation - Sheets Form Submit events

There is a FormResponse class:

Apps Script Documentation - FormResponse

But it can not edit an existing Form response in the Form.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!