r/GoogleAppsScript • • Jun 29 '20

Question Using Google Apps Script to configure OAuth

7 Upvotes

I'm having some trouble configuring my Google Apps Script to properly handle the token that comes from the API I'm reaching out to. Everything from what I can tell is compatible.

I am using the Apps Script oAuth2 here.

When I run the below scripts I am able to get to the oAuth screen where I validate on the app, and when it passes the credentials back to google scripts on user callback i get the below error.

Error: Error retrieving token: {"id":"401","name":"unauthorized","detail":"Unauthorized"} (line 541, file "Service")

My oAuth Script is below:

var CLIENT_ID = '...';
var CLIENT_SECRET = '...';

// configure the service
function getYNABService() {
  return OAuth2.createService('YNAB')
    .setAuthorizationBaseUrl('https://app.youneedabudget.com/oauth/authorize')
    .setTokenUrl('https://api.youneedabudget.com/v1/budgets?access_token')
    .setClientId(CLIENT_ID)
    .setClientSecret(CLIENT_SECRET)
    .setCallbackFunction('authCallback')
    .setPropertyStore(PropertiesService.getUserProperties())
    .setScope('read-only')
    .setGrantType('authorization_code');
}


// Logs the redict URI to register
// can also get this from File > Project Properties
function logRedirectUri() {
  var service = getService();
  Logger.log(service.getRedirectUri());
}

// handle the callback
function authCallback (request) {
  var YNABService = getYNABService();
  var isAuthorized = YNABService.handleCallback(request);
  if (isAuthorized) {
    return HtmlService.createHtmlOutput('Success! You can close this tab.');
  } else {
    return HtmlService.createHtmlOutput('Denied. You can close this tab');
  }
}

My code to invoke this script is below:

// add custom menu
function onOpen() {
  var ui = SpreadsheetApp.getUi();
  ui.createMenu('YNAB for Sheets')
      .addItem('Authorize','showSidebar')
      .addItem('Fetch Budget','makeRequest')
      .addItem('Reset','reset')
      .addToUi();
}


/***************************************/
// Show sidebar for Authorization
function showSidebar() {
  var YNABService = getYNABService();
  if (!YNABService.hasAccess()) {
    var authorizationUrl = YNABService.getAuthorizationUrl();
    var template = HtmlService.createTemplate(
        '<a href="<?= authorizationUrl ?>" target="_blank">Authorize</a>. ' +
        'Reopen the sidebar when the authorization is complete.');
    template.authorizationUrl = authorizationUrl;
    var page = template.evaluate();
    SpreadsheetApp.getUi().showSidebar(page);
  } else {
  // ...
  }
}

function reset() {
  getYNABService().reset();
}


function makeRequest() {
  var YNABService = getYNABService();
  var response = UrlFetchApp.fetch('https://api.youneedabudget.com/v1/budgets/default/accounts', {
    headers: {
      Authorization: 'Bearer ' + YNABService.getAccessToken()
    }
  });
  // ...
}

r/GoogleAppsScript • • Apr 01 '20

Guide PSA - New V8 Runtime / Chrome / Multiple Logged in accounts

7 Upvotes

Just a heads up, it appears that being logged into multiple accounts in Chrome while using the new V8 runtime can cause some unexpected issues with using google.script.run.

Seemingly all executions are ran as your primary logged in account, rather than the account you're accessing the google document with. This seemingly was not the case with the previous runtime.

To recreate, feel free to make a copy of this spreadsheet while being logged into multiple accounts, and do it with the non-primary account. https://docs.google.com/spreadsheets/d/1iBHKWZOqd-xe56MdXdVR4QdQfSKfY6hg5YajHX9qVMQ/edit#gid=0

When you try to run the demo menu and then check the logs, you'll see nothing is there. If you check your executions, ran by you, you'll see that processing menu option was not ran. If you look at executions by anyone, you'll see it's there but that it has failed.

Then run it from your primary account, and it works. Or stay with your secondary account, change the runtime, in the manifest.json file,to stable and once again it works. You'll also notice that the execution you tried earlier was ran by unknown and the stable execution was ran as a web app.

Not sure who needs to see this, but hopefully it'll save someone a bit of hassle down the line.

Oh and ps sorry for the menu being bifurcated and oddly stitched together in the testing function, that was due to testing everything I could think of to try to figure out why it wasn't working properly.


r/GoogleAppsScript • • Mar 18 '20

Resolved google apps scripts V8 buggy anyone else having issues with passing event objects?

7 Upvotes

I've had to keep all my scripts on the DEPRECATED_ES5 setting because scripts in V8 doesn't pass the event on form submit, no logging...just buggy. Anyone else having issues with the change? I really would love to use the modern syntax but...I need the event object from my forms more! If anyone has a workaround i'd appreciate it =)


r/GoogleAppsScript • • Mar 13 '20

Resolved Help with "simple" script for google sheets?

7 Upvotes

I'm trying to create script that helps me hide rows that don't contain a specific cells value

I want to be able to type in C1 and have it hide the results in a range of B3:F where the column B does not contain the text of C1.

So if i type "Fish" in C1 than only the rows containing the word fish will show up below. this is already something that working with the filter option within a range, but i want it to be a little more clean instead of having to click the filter header and changing the text and clicking ok each time.

Is this something even doable?


r/GoogleAppsScript • • Sep 02 '19

How do I use this app script to work with Google form to google sheets to google calendar - for scheduling?

7 Upvotes

Gsuites offers this explanation but I can’t get past the part about the skeleton script?

I want to use the form to populate a spreadsheet that will create new events on the calendar - should be able to update and change in real time.

Can this be done as Gsuits recommends?


r/GoogleAppsScript • • Jun 07 '19

Just how large a script can a write while maintaining reliability?

7 Upvotes

This is my first script and i've only been coding for a month. At this point i'm at 600 lines of code and 4 HTML sidebars attached to a google sheet. It is fully functional and reliable. I'm somewhat obsessive and have really dived head first into coding.

  1. Does the size of the code and html files increase the amount of time it takes your menus to populate and become usable?

  2. I'm at 600 lines of code now. How much can I write before stability becomes a factor. I have big plans and much more to write.

I'm loving coding. I haven't played computer games since I started. This is incredible. I wish I had tried this sooner.


r/GoogleAppsScript • • Mar 04 '19

Parsing and Scraping website with login

7 Upvotes

Has anybody been able to parse, scrape, and login to a website with scripts? Looking to download content like images post login form.


r/GoogleAppsScript • • Jul 24 '26

Question My first Apps Script, any feedback?

6 Upvotes

Hello, as a freelancer building toward an agency, I struggled to find a workflow tool that truly fit: from ClickUp and Notion to Airtable. Since I already use Google Workspace, I decided to build my own solution using Google Apps Script.

I’m using this project to genuinely learn programming. No 'vibe-coding' without understanding the mechanics.

I'm trying to integrate many systems:
- Content creation
- Prospecting pipeline
- Sales pipeline
- Delivery
- Finance

This is just the start, and I can always migrate to other tools as I scale. I’d love your feedback on whether this is a solid path worth pursuing!

Update August 1th :


r/GoogleAppsScript • • Jul 13 '26

Question Any tips to build automation certain spreadsheet cel into pdf file?

6 Upvotes

My job is :

  1. Based on vlookup formula and then input customer code to open their receipt.

  2. Copy their receipt by select certain area of their receipt.

  3. Print it to save into PDF, and then rename the file into customer name.

i discovered google app script able to do it automatically in just one click, and i want to learn it, but i want to focus on fundamentals and my specific issues? thanks in advance


r/GoogleAppsScript • • May 09 '26

Resolved Built a fully automated multi-form data pipeline for my company using Google Sheets + Apps Script - no paid tools, no third-party software

6 Upvotes

Hey everyone,

I work at a printing and publishing company in India. Our team was drowning in WhatsApp messages, emails, and scattered Excel files just to track client enquiries, payments, and expenses. Nothing was centralised. Data was getting lost or mismatched between departments.

So I decided to build a solution from scratch - using only Google Forms + Google Sheets + Apps Script. Zero paid tools. Zero third-party software.

Here's exactly what I built and how.

The Problem

We had three completely separate workflows running at the same time:

BD (Business Development) team - capturing client enquiries (product type, size, quantity, target price)

Finance team - logging payments received from clients

HR/Admin team - recording expense transfers to vendors

All three teams were working in silos. There was no single place to see everything happening across the company in real time.

The Solution - A Unified FMS (Flow Management System)

I built a 3-form → 1 master sheet pipeline entirely in Google Sheets.

How it works:

Any team member submits their respective Google Form

Google automatically stores the raw response in its linked tab (Forms_Report, Payment_Report, or Expense_Report)

An Apps Script trigger fires instantly on form submit

The script detects WHICH form was submitted by reading the sheet name

It maps the data by header name (not column position) - this prevents any mismatch if form fields are reordered

A unique ID is auto-generated: BDE0001 for enquiries, PAY0001 for payments, EXP0001 for expenses

The row is appended to the Master sheet with colour coding by type

The Pending tab auto-refreshes to show only unresolved items

Results

Zero manual data entry into Master sheet - everything is automated

All three departments see their work reflected in one place

Team can freely edit any cell - no formula locks breaking (Apps Script writes values, not formulas)

Status tracking - team manually updates K column to "Done" → item disappears from Pending tab automatically

BD Report tab shows performance per specialist - total enquiries, pending, done, last submission date.

What's next

Email notifications when a new enquiry comes in

WhatsApp integration via webhook for instant alerts

Dashboard tab with charts using Google Sheets built-in charting

Tools used: Google Forms, Google Sheets, Google Apps Script Cost: ₹0

Happy to answer any questions or share the script. This took me about a day to build iteratively - testing, breaking, fixing, and refining. If your company runs on scattered forms and WhatsApp groups, this approach is 100% worth building.


r/GoogleAppsScript • • Apr 23 '26

Question Activity History not showing

6 Upvotes

Problem Description:
I have a Google Apps Script web app tracker. The login, logging of data to the spreadsheet, and timer are all working fine on both Mac and Windows. However, the data fetch functions (getHistory and getAllUserStatus) fail to display any data on Windows (Chrome/Edge), while they work perfectly on Mac (Safari/Chrome).

On Windows, the browser console shows: Uncaught ReferenceError: isOver is not defined. This variable is declared inside a forEach loop. This suggests the loop is not being entered at all, likely due to a data serialization issue or a "silent" backend error.

Current Setup:

  • Backend (Code.gs): Fetches values from Google Sheets using getValues(), filters them, and returns an array of objects.

  • Frontend (index.html): Uses google.script.run.withSuccessHandler() to receive the data and build an HTML table via forEach.

Code Snippets:

Backend (getHistory):

javascript

function getHistory() {
  const info = getUserInfo();
  const sheet = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName(TASKLOG);
  const lastRow = sheet.getLastRow();
  if (lastRow < 2) return [];
  const data = sheet.getRange(2, 1, lastRow - 1, 6).getValues();
  let logs = [];
  for (let i = data.length - 1; i >= 0; i--) {
    if (String(data[i][1]).toLowerCase().trim() === info.email) {
      logs.push({ time: data[i][0].toISOString(), action: data[i][2], detail: data[i][3], duration: data[i][5] });
    }
    if (logs.length === 10) break;
  }
  return logs;
}

function getHistory() {
  const info = getUserInfo();
  const sheet = SpreadsheetApp.openById(SPREADSHEET_ID).getSheetByName("Tasklog");
  const data = sheet.getDataRange().getValues();
  let logs = [];
  for (let i = data.length - 1; i > 0; i--) {
    if (String(data[i][1]).toLowerCase().trim() === info.email) {
      logs.push({
        time: data[i][0] instanceof Date ? data[i][0].toISOString() : String(data[i][0]),
        action: data[i][2],
        detail: data[i][3],
        duration: data[i][5]
      });
    }
    if (logs.length === 10) break;
  }
  return logs;
}

Frontend (loadHistory):

javascript

function loadHistory() {
  google.script.run.withSuccessHandler(data => {
    let html = "";
    data.forEach(x => {
      let d = new Date(x.time), dur = "";
      let isOver = false;
      if(x.duration !== "") { 
        let mins=Math.floor(x.duration/60), secs=x.duration%60; 
        dur=` | ⏳ ${mins}m ${secs}s`; 
        if(x.action.includes("Break") && x.duration > 1800) isOver = true;
        if(x.action.includes("Lunch") && x.duration > 3600) isOver = true;
      }
      let durStyle = isOver ? "color: #e74c3c; font-weight: bold;" : "color: #3498db;";
      html += `<div class="history-item"><b>${x.action}</b> <span style="color:gray; font-size:11px;">(${x.detail||'--'})</span><br><small style="color:#95a5a6;">${d.toLocaleDateString([], {month:'short', day:'numeric'})} | ${d.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'})} <b style="${durStyle}">${dur}</b></small></div>`;
    });
    document.getElementById("history").innerHTML = html || "No logs.";
  }).getHistory();
}

function loadHistory() {
  google.script.run.withSuccessHandler(data => {
    let html = "";
    data.forEach(x => {
      let d = new Date(x.time), dur = "";
      let isOver = false;
      if(x.duration !== "") { 
        let mins=Math.floor(x.duration/60), secs=x.duration%60; 
        dur=` | ⏳ ${mins}m ${secs}s`; 
        if(x.action.includes("Break") && x.duration > 1800) isOver = true;
        if(x.action.includes("Lunch") && x.duration > 3600) isOver = true;
      }
      let durStyle = isOver ? "color: #e74c3c; font-weight: bold;" : "color: #3498db;";
      html += `<div class="history-item"><b>${x.action}</b> <span style="color:gray; font-size:11px;">(${x.detail||'--'})</span><br><small style="color:#95a5a6;">${d.toLocaleDateString([], {month:'short', day:'numeric'})} | ${d.toLocaleTimeString([], {hour:'2-digit', minute:'2-digit'})} <b style="${durStyle}">${dur}</b></small></div>`;
    });
    document.getElementById("history").innerHTML = html || "No logs.";
  }).getHistory();
}

Use code with caution.

What I've tried:

  1. Declared isOver outside the loop.

  2. Used new Date(timestamp).getTime() to pass numbers instead of Date objects.

  3. Checked Spreadsheet permissions (User is an Editor).

  4. Tried New Deployments and Hard Refresh (Ctrl+F5).

Question:
Why would google.script.run fail to pass/process the array specifically on Windows environments while working on macOS? Are there known issues with Date serialization or specific browser security settings in Windows that prevent the withSuccessHandler from receiving the data?


r/GoogleAppsScript • • Apr 20 '26

Question A call for support - Please upvote issue# 504194149 on Google's Issue Tracker

6 Upvotes

This issue has a fairly long history. Allow me to elaborate.

Gmail API Push Notifications was released in 2015 and for around 2 to 3 years, it was possible to use this feature directly from a consumer-grade/personal account using the default Google-managed GCP project linked to a GAS project WITHOUT jumping through too many hoops.

Back then we could access the google-managed project from the google developer console, enable the Pub/Sub API, create a Pub/Sub topic to receive real-time notifications from Gmail for various events (new incoming email, sent email, etc.) and wire up a GAS Web App as the target for a Pub/Sub push subscription to process said notifications.

That ended in 2018, with the shift towards a stronger stance on User Data Privacy. From then on, users were no longer able to access google-managed GCP projects from the Google Developer console and the ability to enable the Pub/Sub API on the default Google-managed GCP project was also disabled.

Today we have to link the GAS project to a GCP standard project, and by virtue of having services with restricted scopes (Gmail), go through a verification process for scripts intended solely for private/individual use on a consumer account.

In this instance, I think Google overcorrected in their efforts to secure their platform in order to comply with GDPR, CCPA and other regulatory bodies.

While the verification process makes sense for apps that will be deployed publicly - for scripts meant for private use on a consumer account - those steps are superfluous. Some try to workaround this by staying in "testing" mode (applicable to GAS projects linked to a standard GCP project). However, OAuth refresh tokens and access tokens expire after 7 days, forcing users to manually reauthorize their scripts - not a good approach if your goal is to automate a process.

I think there is a better middle ground, where Google can be compliant and where users with consumer accounts can enjoy the benefits of services that leverage API Push Notifications using Pub/Sub.

The Solution: Make Pub/Sub an Advanced Service.

As an advanced service, the default Google-managed GCP project can transparently enable/disable the Pub/Sub API and allow devs to use the service seamlessly with far fewer steps.

If you are in agreement on this matter, upvote the issue using the link below: https://issuetracker.google.com/issues/504194149


r/GoogleAppsScript • • Apr 19 '26

Question `SpreadsheetApp.getActiveSpreadsheet()` suddenly stopped returning

6 Upvotes

I have a sheets+apps scripts project that has been working unchanged for months. Suddenly today script entrypoints stopped working, and I traced it to SpreadsheetApp.getActiveSpreadsheet no longer returns.

I tried:

  • change to SpreadsheetApp.openById, still fails to return

  • force a full re-authorization; I got the prompt to allow access, but then still hangs forever

  • made a copy of the sheet, still fails to return in the same way (and ditto updating the id to try to open)

I have a different sheet+app scripts project that seems to still be working ok.

I'm out of ideas on what more to try here.

Edit update: 12 hours later it now works fine. Gah!


r/GoogleAppsScript • • Apr 19 '26

Question Best architecture practice for a GAS Sheets WebApp

6 Upvotes

To set some context: I'm an old-skool dev (mostly Mainframe) with a CS degree from the mid-90s. I get classes and the like, and I understand the principles of OOP, but I'm struggling to figure out the best architecture design for a project I'm doing, so wanted to discuss with the hive-mind.

I've created one webapp in a pinch, and it follows absolutely no good practice. Not a single class to be found anywhere.

This new one is for a sport club, so has very obvious (even to me) classes. My JS is robust enough for reading, tweaking and small fixes, and improving any obvious bloat, but trying to start from scratch is a stretch for me. Hence my use of AI. <insert gnashing of teeth here>.

Trying to start off in a good way, with models, repos and views, but I still then get a bit "should I add in a service layer?" and what goes where? What's -js.html and what's .gs?

Any hints/suggestions/links I can go to to help? Claude suggests one thing, GPT another... GPT is very keen on view/controller/service/repo... Am I complicating this?

How do you design and organise your projects?

edit: I am using VSCode and clasp, so organisation is fine.


r/GoogleAppsScript • • Apr 08 '26

Question Google Apps Script for multi-brand reporting automation

6 Upvotes

Need advice on setting up a reporting automation.

I want to automate daily reporting for multiple brands where:

gross sales come from Shopify

Meta ad spend comes from Meta Ads Manager

Google ad spend comes from Google Ads

and all of it goes into one Google Sheet in fixed columns for each brand.

Main idea is to have one target sheet where every day the numbers update or append automatically.

I’ve been hearing that Google Apps Script can do this and since it comes with a Gmail account, there’s some free execution time (around 6 minutes?), so I’m wondering if that’s enough for something like this.

What I’m trying to understand:

Is Apps Script a practical way to do this?

Where does it usually get difficult — API auth, tokens, limits, etc.?

If multiple brands are involved, does it still stay manageable?

If anyone has built something similar, would appreciate knowing how you approached it.


r/GoogleAppsScript • • Mar 21 '26

Guide I got tired of counting hours from my calendar every month, so I built a Google Sheets tool that does it in 3 seconds

6 Upvotes

Hey, can I be honest with you for a second?

Every month I was doing the same thing — staring at my Google Calendar, counting hours into a blank spreadsheet. "Was that Client A or B?" "Did sprint review count as Development or Meetings?"

So I built Calendar Time Tracker — a Google Sheet with Apps Script that reads your calendar, auto-tags events by keyword, and generates a time report in 3 seconds.

No API keys. No installs. No monthly fees.

I open-sourced it on GitHub — link in comments!


r/GoogleAppsScript • • Mar 04 '26

Question Vibe coding a Telegram expense bot with Google Apps Script — complete beginner, completely lost. Anyone been through this?

6 Upvotes

Hey everyone,

I'll be upfront — I am vibe coding this entire thing. I'm not a developer. I'm a finance guy (FP&A, SQL, Power BI) and I thought building a simple Telegram bot to track expenses in Google Sheets would be a fun side project. Several weeks and honestly too many hours later, I'm at my wit's end.

The concept is dead simple: text the bot "Starbucks 5.50," it logs to a Google Sheet, shows category buttons, lets you add an optional note or skip it, and supports two users (me and my wife). That's it.

Here's what I've been dealing with:

  1. 302 Moved Temporarily errors

Telegram's webhook keeps hitting a redirected or stale endpoint instead of my actual deployed script, causing all incoming messages to silently fail.

2. Webhook URL breaks on every redeployment

Apps Script generates a new URL every time I push an update, so I have to manually reset the webhook each time or nothing works.

3. Deployment versioning is a nightmare

I've accidentally archived working deployments trying to push updates, orphaning the webhook and sending me back to square one.

4. Bot goes completely silent with no errors

Execution log says "Completed," webhook shows connected, but the bot stops responding and queues up 14+ unprocessed messages with no indication of why.

5. Callback queries ignored

Tap a category button, nothing happens. No error, just silence.

6. Duplicate expense entries

The same message sometimes gets logged 2-3 times in the sheet, likely because Telegram retries unacknowledged webhooks.

7. Infinite loops

The conversation flow occasionally gets stuck and the bot starts repeating the same prompt over and over, unable to advance its own state.

8. High latency

Response times swing between 1-2 seconds and 10-15+ seconds. The timeouts cause Telegram to retry, which feeds back into the duplicate problem.

9. The "add a note or skip" flow is completely broken

After selecting a category, the bot should prompt you to type a note or tap Skip. Instead it either loops back to the start, skips the prompt and saves immediately, or gets stuck where no input is recognized. The session and cache handling for this multi-step flow has been the most painful part of the whole build.

I've gone through 37+ iterations trying to fix these. I've even looked at switching to Make.com and n8n just to escape the Apps Script deployment cycle.

Here's what I actually want to know:

Is there a proper structured way to build this that avoids all these pitfalls? And more specifically — has anyone written solid instructions or a prompt that would let Claude (or another AI) build this end-to-end without running into all these traps?

If you were handing this project to an AI assistant and wanted a working result on the first or second try — what would that prompt look like? What context does it need? What mistakes should it be told to avoid upfront?

I feel like the knowledge exists somewhere. I just don't have it, and I've been learning the hard way one broken deployment at a time.

Any help, pointers, or even just a "here's what you're missing" would mean a lot. 🙏

Edit

For those interested, after a deep dive, I discovered that latency issues were the root cause of the problem. I ended up redesigning my bot’s workflow — instead of having the bot ask if I wanted to add a note after logging an expense to the sheet, I modified the code to include all the information in a single message (for example: “Amazon 25.00 #SecretSanta gift”). The key change was having the bot recognize everything after the hashtag as a note and log it in the note column. That simple adjustment resolved everything — no more 302 errors, duplicates, or loops. I’m now working on a KPI engine, charts, a forecasting sheet, and a dashboard. The bot is live and running flawlessly.


r/GoogleAppsScript • • Dec 22 '25

Guide I felt the pain of building Google Editors add-ons. So I packaged everything I learned into a production-ready boilerplate.

6 Upvotes

React, auth, Supabase, Stripe, all wired up. Live reloading, one codebase for multiple add-ons, and a structure ready for production.

Here’s a deep dive into how it works:
https://www.shipaddons.com/docs/quick-overview

I’d love to hear your feedback. The boilerplate is currently in beta and available as "pay-what-you-want", mainly to collect as much feedback as possible and improve it.

This would have saved me a ton of time when I started building google add-ons, hopefully it can save you some time too.

Even if you don’t want to pay anything, that’s totally fine, the documentation, tutorials, and guides I’m sharing are meant to help everyone.

Cheers!


r/GoogleAppsScript • • Dec 20 '25

Guide Secure Secrets in Google Apps Script

Thumbnail justin.poehnelt.com
6 Upvotes

TLDR: Do not hardcode secrets in Google Apps Script. Use Properties Service or Google Cloud Secret Manager.


r/GoogleAppsScript • • Dec 15 '25

Question Getting URL for deployed Web App

6 Upvotes

I have three simple Forms - Form A, Form B, Form C - without associated Apps Script projects.

I have a separate Apps Script project, called Centralise, containing a function globalOnFormSubmit() that is to be called when anyone submits a response to any of the three Forms. The trigger is registered by three one-time calls using each of the Form's form IDs:

ScriptApp.newTrigger('globalOnFormSubmit')
.forForm(formId)
.onFormSubmit()
.create();

globalOnFormSubmit parses the current Form response and sends an email to me if the inputs meet certain criteria (e.g., all questions have unique responses).

So far, so good. globalOnFormSubmit is called every time a Form receives a submission, is able to identify the ID of the Form whence the response came, and correctly retrieves the actual values entered by the submitter.

The Centralise project is also deployed as a Web App (run as: Me, access: Anyone with a Google account), displaying a simple HTML dashboard with the results from the three Forms.

So far, so good.

Now the weirdness. I'm calling ScriptApp.getService().getUrl() inside globalOnFormSubmit to get a link to the deployed Centralise web page. But it returns a link that doesn't load and doesn't correspond to any Forms or Scripts that I own. ScriptApp.getService().isEnabled() returns true.

Why does this happen, and how do I get my centralised globalOnFormSubmit function to get the link for the current deployment?


r/GoogleAppsScript • • Dec 06 '25

Guide Movie Tracker built with Google Apps Script + iOS Shortcuts (GitHub repo included)

6 Upvotes

I’ve been working on a minimal but highly functional movie-tracking system that uses Google Sheets, Google Apps Script, and iOS Shortcuts.

Github Repo

What it does:

The setup connects a Google Sheet to a set of iOS Shortcuts so you can:

  1. Add new movie titles from your phone

  2. Pull a clean list of unwatched movies

  3. Mark any movie as “Watched” (auto-archived into a separate tab)

  4. Fetch metadata via OMDb/TMDb with a batchable custom function

  5. Keep everything serverless—no external hosting, tokens, servers, etc.

  6. Everything is handled using a single /exec web app endpoint from Apps Script.

How it works:
Sheets (4 tabs)

  1. TITLES – raw input from shortcuts

  2. Watch List – main queue

  3. Watched – auto-archive when marked done

  4. Not Watched – optional manual list using the formula =IFERROR(FILTER('Watch List'!$A$2:$J, 'Watch List'!$K$2:$K=FALSE), "")

Apps Script (modularized):

  1. webapp.js → GET/POST logic

  2. sheets.js → constants + grid ID handling

  3. movies_api.js → OMDb + TMDb metadata helpers

  4. custom_functions.js → GET_MOVIES() + GET_HEADERS()

The Apps Script project is fully managed using clasp and version-controlled inside the repo. Of course working in the Apps Script IDE the extensions will be .gs rather than .js

iOS Shortcuts (4 shortcuts):

  1. add-title.shortcut

  2. mark-watched.shortcut

  3. get-unwatched-list.shortcut

  4. MOVIE-TRACKER.shortcut (a main menu that calls the others)

Each Shortcut simply interacts with the web app using GET or POST requests.

Why post this:
If you’re into Apps Script automation or Shortcut workflows, this might be useful as a reference project or a starting point.

Feedback welcome!

If you spot bugs, want new features, or think parts of the project could be improved, feel free to reach out.

Repo link again:
https://github.com/ambiguousaccess/movie-tracker


r/GoogleAppsScript • • Nov 08 '25

Resolved Fastest way to search through an array multiple times?

6 Upvotes

I created a script to find all emails that have not been added to a list then move the values to the new list. I was wondering if there was a faster way.

function compareEmails() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var dataSheet = ss.getSheetByName('Data');
  var dataEmails = dataSheet.getRange(2,10,dataSheet.getLastRow()-1).getValues().flat();
  //console.log(dataEmails)

  var joinedSheet = ss.getSheetByName('Combined');
  var joinedEmails = joinedSheet.getRange(2,10,joinedSheet.getLastRow()-1).getValues().flat();
  //console.log(joinedEmails)

  var uniqueEmails = []

  for (var i = 0; i < joinedSheet.getLastRow() - 1; i++) {
    var email = joinedEmails[i];
    var index = dataEmails.indexOf(email);
    //console.log(index);
    if(index < 0){
    //console.log(dataEmails.indexOf(email))
    console.log(email)
    var newRow = joinedSheet.getRange(i+2,1,1,11).getValues().flat();
    uniqueEmails.push(newRow)
    }
  }

  console.log(uniqueEmails);
  var newEmailsRange = dataSheet.getRange(dataSheet.getLastRow()+1,1,uniqueEmails.length,11)
  newEmailsRange.setValues(uniqueEmails);
}

My first thought was to add

else { dataEmails.splice(index,1) }

to shrink the length of the array as it goes but that did not seem to make it any faster.


r/GoogleAppsScript • • Sep 11 '25

Guide Turning Google Docs and Sheets Into a Mini Translator

6 Upvotes

A client came to me with a tiny challenge they had a glossary in Google Sheets with translations and wanted Google Docs to magically highlight terms and show the translation in a comment.

I thought, “Let’s see if I can make Docs and Sheets talk.” 😎

After some tinkering with Google Apps Script, I built a core demo it checks your Docs text, highlights matching terms, and drops the translated term in a comment. Simple, but seeing it actually work felt like magic.


r/GoogleAppsScript • • Aug 22 '25

Question How do I prevent "clasp push" until code is merged to master?

6 Upvotes

My team's workflow is mostly Python and R. We manage deployments through gitlab, but GAS has recently become a super useful tool for moving data between GCS and Sheets. At the moment, we're using clasp to pull/push and manually syncing with gitlab as we go. I want to enforce a rule where you can't clasp push your project unless you're on the master git branch, meaning you need to make a pull request and have your work reviewed and approved first. Any way to do this? Or do I need to go down a different route?