简体   繁体   中英

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

I have a form in the google form that is about getting data from users, I need to get the user's phone number from the google sheet after the user submits his/her information in google form and send the verification SMS to them.

I want to get an Event form to submit button, google has a submit function in its documentary but I don't know how its works or how can I use it because there is no example there!

I wrote all code for this, I just need to talk with the submit button.

You can use the following function -

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
}

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM