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

241
Visualizações
Google Web App google.script.run not working

I have the following .gs:

function doGet(e) {
  return HtmlService.createHtmlOutputFromFile('index')
}

function goToMaster() {
  const ss = SpreadsheetApp.getActiveSpreadsheet()
  const sheet = ss.getSheetByName('Master Projects')
  sheet.activate()
}

The goToMaster() function activates a sheet called "Master Projects"

When running the function by itself, it works properly. However I created an index.html ui to trigger this function by clicking on a div:

<!DOCTYPE html>
<html>

<head>
  <base target="_top">
  <link rel="icon" href="/images/favicon.svg" />
  <script src="https://kit.fontawesome.com/abd2f5db30.js" crossorigin="anonymous"></script>
</head>

<body>
<div class="card card--1" id="master-projects">
      <div class="container">
        <h2>Master Projects</h2>
        <i class="fa-solid fa-diagram-project"></i>
      </div>
<script>
    const masterProjects = document.getElementById('master-projects');
    masterProjects.addEventListener('click', doStuff);

  function doStuff() {
    google.script.run.goToMaster();
  }    

  </script>
</body>  

 </html>

When clicking the div, nothing happens! I looked everywhere to find a solution but nothing has worked so far.

Any idea what might be causing this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try it like this

html:

<!DOCTYPE html>
<html>

<head>
  <base target="_top">
  <link rel="icon" href="/images/favicon.svg" />
  <script src="https://kit.fontawesome.com/abd2f5db30.js" crossorigin="anonymous"></script>
</head>

<body>
<div class="card card--1">
      <div class="container">
        <h2>Master Projects</h2>
        <i class="fa-solid fa-diagram-project"  id="master-projects"></i>
      </div>
<script>
  window.onload = function() {
    const masterProjects = document.getElementById('master-projects');
    masterProjects.addEventListener('click', doStuff);
  }
  
  function doStuff() {
    google.script.run.goToMaster();
  }    
  </script>
</body>  

 </html>

gs:

function goToMaster() {
  const ss = SpreadsheetApp.getActiveSpreadsheet()
  const sheet = ss.getSheetByName('Master Sheet')
  sheet.activate()
}

function launchadialog() {
  const ui =  SpreadsheetApp.getUi();
  ui.showModelessDialog(HtmlService.createHtmlOutputFromFile("ah2"),"Title")
  
}
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