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

239
Vistas
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 Respuestas
Responde la pregunta

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