It's very likely that you are running the `onformsubmit` function from the script editor which don't send an event object (`e`).

In order to run `onformsubmit` from the Google Apps Editor for debugging purposes, you have to create a an auxiliary function to create the event object and assign the required properties. For a broader explanation see the [answer][4] from Mogsdad to [How can I test a trigger function in GAS?][5]



Related

- https://webapps.stackexchange.com/q/72982/88163
- https://webapps.stackexchange.com/q/104161/88163
- https://webapps.stackexchange.com/q/139838/88163


  [4]: https://stackoverflow.com/a/16089067/1595451
  [5]: https://stackoverflow.com/q/16089041/1595451