title: How do I update fields based on a Google Forms dropdown value?
body: <p>We are using Google Forms to collect data from our field reps while they are out at a job site.  We use a script to fill drop down values for 4 different fields and that runs periodically. This saves them from having to type it out and possible make mistakes.</p>
  
  <p>All of those fields are pre-determined, so if they select Project #1, we already know the values of address, manager, and client.  The values are stored in a second tab of the results form and could theoretically be used as a lookup.</p>
  
  <p>I question whether these fields need to be included at all, but when the user submits the form, the data is then emailed using an add-on and it uses some of those fields in the subject. I suppose the recipients want the info as well.</p>
  
  <p>Can I make my own triggers?  If I had a trigger for when the project ID changed, I would think I could update the others from a spreadsheet.</p>
  
  <p>Or if there was a OnNextPage trigger that I could use to fill those values.</p>
  
  <p>Is there anyway to add/change values when the form is submitted?</p>
  
  <p>I think the following is what I want to do (thanks @OMilo), but I am struggling with the lookups:</p>
  
  <p>function onFormSubmit(e) {
    Logger.log("[METHOD] onFormSubmit");</p>
  
  <p>sendEmail(e.range);
  }</p>
  
  <p>function sendEmail(range) {</p>
  
  <p>// Here we get choice the users selected in the form:
    var itemResponse = e.response.getItemResponses()[1557784536]; // Use whatever index is the item, in my case it's 0.
    var kmbProjectNumber = itemResponse.getResponse();</p>
  
  <pre><code>//LOOKUP KMB PROJECT NUMBER IN SHEET: "New - KMB Design Visit Closeout (Responses)" TAB: "KMB Lookups"
  var ss = SpreadsheetApp.OpenByID('REDACTED');
  var lookups = ss.getSheetByName("KMB Lookups");
  
  //In Column named'KMB Project ID' find record from bottom where value = kmbProjectNumber
  //Get value for column named 'Site Address'
  //Get value for column named 'KMB Project Manager'
  //Get value for column named 'Client Assigning this Work'
  
  // FETCH SPREADSHEET //
  var values = range.getValues();
  var row = values[0];
  
  //WRITE FOUND VALUES TO SPREADSHEET
  //Set row[3] to Site Address
  //Set row[4] to Project Manger
  //Set row[5] to Client
  
  var svProjectManager = row[4]; //Update manually  //E
  var svClient = row[5]; //Update manually  //F
  
  // EXTRACT VALUES //
  var svTimeStamp = row[0];  //A
  var svInitials = row[1];  //B
  var svProjectID = row[2];  //C
  var svSiteAddress = row[3];  //Update manually    //D
  var svProjectManager = row[4]; //Update manually  //E
  var svClient = row[5]; //Update manually  //F
  var svNOCNeeded = row[6];  //G
  
  
  // PREPARE EMAIL //
  var emailRecipients = "REDACTED";
  var emailSubject = "Field Visit Completed for "+svProjectManager+" "+svProjectID;
  var emailBody = ""  //Format using variables set
  
  // SEND EMAIL //
  </code></pre>
  
  <p>}</p>