0

I have a spreadsheet that is populated with data via a google form. I also have a Google App script associated with the response spreadsheet. The script has several versions that do slightly different things and I need to run a specific version of the script based on a cell value in the response sheet. The problem is it always needs to be the last cell in column "J" with data in it.

For example, the form gets submitted and populates row 5. I need the "if statement" to look in J5. The next time the form is submitted it will populate row 6. That time I need the "if statement" to look in J6. And so and so on.

I'm fairly new to google app script, but I'm familiar with if statements.

Any help is greatly appreciated.

1

If your script runs when the form is submitted, then presumably it is triggered on form submit. In this case, the function will receive an event object, in which the property values is the array of values submitted. This is the preferable way to access just-submitted form values, compared to fetching them from responses sheet.

The function would be like,

function processForm(e) {
  if (e.values[9] == 'something') { 
    // do something
  }
  else {
    // do something else
  }
}  

Here the index is 9 because J is the 10th letter of the alphabet, and JavaScript index begins with 0.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.