babak abdzadeh
babak abdzadeh

Reputation: 79

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.

Upvotes: 1

Views: 117

Answers (1)

Sourabh Choraria
Sourabh Choraria

Reputation: 2331

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.

Upvotes: 1

Related Questions