'Form title from FormResponse

I have created a bunch of forms programmatically from a spreadsheet and bound a response trigger to each. When a form is filled out I can't seem to figure out which form was completed.

I tried:

Event.source.getId() 

But that returns the id of the spreadsheet. I want to get the title of the form.

Edit: Clarification

This is how I set up the trigger:

ScriptApp.newTrigger('responseTrigger').forForm(form)
 .onFormSubmit()
 .create();

And when I try to get the title:

function responseTrigger(e) {
  var source = e.source;
  var title = e.source.getTitle().
  Logger.log(title);
}

I get the following error:

Execution failed: TypeError: Cannot find function getTitle in object Spreadsheet.



Solution 1:[1]

How about this?

If you want to retrieve the title when the form was submitted, you can use following script.

var title = e.source.getTitle()

If you always want to retrieve the title, you can use following script.

var form = FormApp.openById( form ID );
var title = form.getTitle();

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tanaike