Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!