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

482
Vistas
How to pass event object to .onChange() trigger in Google Apps Script

I'm trying to add a trigger to my Google Sheet so that a certain function is run (say for example an alert is to ui) when any sheets are renamed.

I found the following post that explains a workaround Event on rename worksheet tab not triggered but I'm not sure if this will actually work because it is not what document this listener is supposed to listen to.

From my previous experience writing successful even triggers for Google Forms we have to use a trigger builder like the following example. Now if I want to pass the event to myFunction in the following code how do I do it?

let currentSs = SpreadsheetApp.getActive();

ScriptApp.newTrigger('myFunction')
.forSpreadsheet(currentSs)
.onChange()
.create();

function myFunction() {
 if event.changeType === 'Other' {
  //do this
 }
}
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this:

function createTrigger() {
  if (ScriptApp.getProjectTriggers().filter(t => t.getHandlerFunction() == "myFunction").length == 0) {
    ScriptApp.newTrigger("myFunction").forSpreadsheet(SpreadsheetApp.getActive()).onChange().create();
  }
}

function myFunction(e) {
  if (e.changeType == 'OTHER') {
    //do this
  }
}
about 4 years ago · Juan Pablo Isaza Denunciar
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