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

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

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 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