Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

240
Vistas
Google Apps Script trigger function runs twice

I have the following trigger setTrigger() set for when a Google Form is submitted. For testing purposes I created a simple function triggerFunction() that creates a .txt file in my Google Drive.

function setTrigger() {
  ScriptApp.newTrigger('triggerFunction')
  .forForm("formId")
  .onFormSubmit()
  .create();
}

function triggerFunction() {
  let folderId = [folderId];
  let blob = ['This is my blob'];
  DriveApp.getFolderById(folderId).createFile('file.txt',blob);
}

Now when I run the triggerFunction() manually it acts normally. It creates a file.txt in my folder. But when I submit a form on my Google form with formId it creates two separate file.txt files! How do I keep the trigger from running the function twice?!

I have tried the following but it still runs the function twice.

function setTrigger() {
  if (ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "triggerFunction").length == 0) {
    ScriptApp.newTrigger('triggerFunction').forForm("formId").onFormSubmit().create();
  }
}
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda