Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

166
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda