如何从 Google 表单提交按钮 运行 Google sheet 脚本?

How to run Google sheet script from the Google form submit button?

我在 google 表单中有一个关于从用户获取数据的表单,我需要从 google sheet 之后获取用户的 phone 号码用户以google形式提交his/her信息并发送验证短信给他们。

我想要一个事件表单来提交按钮,google在它的文档中有一个提交功能,但我不知道它是如何工作的,也不知道我该如何使用它,因为那里没有例子!

我为此编写了所有代码,我只需要与提交按钮交谈即可。

您可以使用以下功能-

function onFormSubmit(e) {
  var formItems = FormApp.getActiveForm().getItems();

  var userPhoneNumber = e.response.getResponseForItem(formItems[x]).getResponse();
  // replace 'x' with 0 if phone number is the first item or
  // with the actual number depending on the nth item of your form
  // (i.e. if userPhoneNumber is the 2nd item, replace x with 1,
  // if its the 3rd item, replace x with 2 etc.)


  // now you write your function to trigger SMS to the 'userPhoneNumber' value
}

希望对您有所帮助。