title: Google Apps Script OnSubmit Function Triggered by Specific Form Submission
body: <p>I have the same question as the user here:
  <a href="https://stackoverflow.com/questions/25227987/google-apps-script-specifying-form-for-on-form-submit-trigger">Google Apps Script - specifying form for &#39;on form submit&#39; trigger</a>
  2 forms tied to different tabs in a spreadsheet that I want to trigger 2 separate functions on submission of the respective form. </p>
  
  <p>Following the answer given, I tried the following code but the functions did not trigger on the submission of those forms for some reason.</p>
  
  <pre><code>var form1 = FormApp.openById('FormID1');
    ScriptApp.newTrigger('OnForm1SubmitFunction')
     .forForm(form1)
     .onFormSubmit()
     .create();
  
  OnForm1SubmitFunction() {
     blah;
  }
  
  var form2 = FormApp.openById('FormID2');
     ScriptApp.newTrigger('OnForm2SubmitFunction')
     .forForm(form2)
     .onFormSubmit()
     .create();
  
  OnForm2SubmitFunction() {
     blah;
  }
  </code></pre>
  
  <p>I could use the other solution given, which uses the standard formsubmit trigger event and a check on the submission fields, eg.
      if(e.namedValues["Untitled Question 2"]!=undefined)
  to determine which form was submitted. But the first solution that ties the function trigger to a specific form, and allows separate functions triggered for each form submission, seems more elegant if I could get it to work.</p>
  
  <p>Any help is much appreciated, thanks!</p>