Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

157
Views
Problem when setting onFormSubmit trigger from spreadsheet to form

I've made a script that builds different forms and they have assigned an onFormSubmit trigger. On the trigger, I have this trouble.

const form = FormApp.getActiveForm()

but the problem is that that script is bounded on the script that builds the forms, not into the form instead. I can't open the form with the Id because it wouldn't work for all the forms

SpreadSheet script

function main(){
 ...
 const formId = form.getId()
  //setup trigger
    ScriptApp.newTrigger('onFormSubmit')
    .forForm(formId)
    .onFormSubmit()
    .create()
}
 function onFormSubmit(e){
  ...
  const formResponse = e.response;
  const date = formResponse.getTimestamp()
  const names = getNames()
  ...
 }

 function getNames(){
  ... 
  const form = FormApp.getActiveForm() //problem
  ...
 }
...
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I've solved it by getting the source info from the event parameter

function onFormSubmit(e){
  ...
  const formResponse = e.response;
  const date = formResponse.getTimestamp()
  const formId = e.source.getId()
  const names = getNames(formId)
  ...
 }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!