r/GoogleAppsScript

AppsScript Help Please - Column O killing functions

Hello all.

I'm hoping someone here can help me because I'm at my wit's end. Long story short, I created and maintain (keep running) a spreadsheet for work that we use to track our service/breakdown department's performance and SLA compliance. Rather than scroll all the way to the bottom of the sheet and manually drag formulae into the new row, I've created a script that inserts a new row and enters the formulae into the top of the sheet. I have the code entering the formulae, instead of copying it, because it works faster than having a script that copy-pastes only the formula into the new row. And my script works a treat, EXCEPT for whatever is happening in column O.

When I remove the code for O, it works just fine. But with the code for column O included it has a shart attack and won't proceed. I've tried moving the data in O to L and the same thing happens. The script works fine until it has to process THAT particular column, then it just stops. Again, removing O from the code makes it work 100%. The code for O and H is almost identical and for all intents and purposes it is, the maths in the formula is a little different is all. I have tried many different versions and functions but the result is the same. It stops at O. I have even tested O with using the SAME EXACT CODE from another work column and it still will not work.

Oddly enough though, a script that simply copy-pastes row 6 into the newly inserted row 5 WILL copy column O, but also all the manually entered data as well which I don't want.

I think I've explained myself well enough. Please ask any questions you may have. My script is below.

https://preview.redd.it/hgxuv63p672h1.png?width=1181&format=png&auto=webp&s=be595498cc1856757dba7ec10da3b5a6524512b0

reddit.com
u/Roasted_Chicken_72 — 9 hours ago
▲ 23 r/GoogleAppsScript+1 crossposts

Google Workspace integration that turns your Gmail into an AI-powered project management suite

Your AI assistant is only as useful as the context it has access to, and since most teams work on Google (drive, docs, gmail, etc.) we developed additional tools to keep all your work in there.

Now, we've also launched AI functionalities through MCP. You can connect to AI apps like Claude, ChatGPT, and Cursor directly to your Tooling Studio workspace. MCP gives your assistant real access to the work you do on Google: tasks, boards, contacts, deals, notes, due dates, and pipeline stages.

Here are some examples:

  • Read the launch meeting notes and create tasks for each owner in the Product board.
  • Find the last email from John Doe and update his contact on the CRM based on what he said.
  • Show me everything in the backlog that is due this week.

Users who have helped us with beta testing loved it, so if this sounds like something that might help you with your work, give it a shot!

https://www.producthunt.com/products/tooling-studio

u/SantiagoSchw — 1 day ago

I'm a lawyer who built a DMS/CRM running entirely on Google Workspace (Sheets + Apps Script + Gemini) — open-sourced

Hey r/GoogleAppsScript,

I'm a Polish attorney running a small law firm (team of 7-8 people). Two years ago I started building a DMS (document management system) directly in Apps Script + Sheets because every commercial option was either too expensive (Clio: $109/user/month, even Polish alternatives are ~$50/seat) or didn't fit my Polish legal workflow.

Honestly — most commercial legal software feels like it was designed by engineers who never sat with an attorney during a deposition.

Today I open-sourced it: https://github.com/apiotrowski-afk/kancelaria-dms

The stack is shamelessly basic:

  • Sheets as database (no Cloud SQL, no Firebase)
  • Apps Script V8 backend (~1050 LOC)
  • Single-file HTML frontend with vanilla JS (~1550 LOC, Bootstrap 5)
  • Gemini API for document summarization + email-to-case matching
  • Gmail Add-on for assigning incoming emails to cases
  • Drive for file storage with auto-created case folders

What it actually does:

  • Tracks cases, parties, courts, deadlines, attorneys
  • Auto-classifies incoming emails to the right case using Gemini (with fallback to client-email matching)
  • Indexes Drive files with AI summaries (knowledge base per case)
  • Polish Post tracking integration (shipment book)
  • Lead/CRM pipeline with conversion tracking
  • Mobile-responsive web app + Sheets sidebar + Gmail Add-on (all from one Apps Script project)

Stuff I learned the hard way:

  • CacheService is your friend — without it, the dashboard was unbearably slow
  • Apps Script's 6-minute execution limit forces you to think about batching from day one
  • Gemini JSON mode (response_mime_type: "application/json") saved me ~80% of parsing logic
  • Drive folder creation in a loop will hit quotas fast — batch your createFolder calls
  • The OAuth scopes for Gmail+Drive+Sheets+Calendar combined create a scary consent screen for users (still no good solution beyond explaining it in onboarding)

Heads up on scope: This is built for EU (specifically Polish) legal workflows — case numbering, court hierarchy, Polish Post integration, GDPR-flavored data handling. Adapting it to US/UK law firms or other jurisdictions would need real work. That said, the architecture is generic enough that any small business running on Google Workspace and dealing with documents could fork it as a starting point.

A note on the code: I'm an attorney, not a professional developer. I use AI assistants heavily for syntax and implementation, but every architectural decision, every piece of domain logic, every integration pattern is mine. After 2 years of running this in production on real client data, I know exactly what each function does and why. The code isn't elegant by senior-dev standards, but it works and it's been battle-tested.

Why open source: Built it for myself, but if it helps another lawyer/dev who needs a starting point for a Workspace-native business app, even better. Apache 2.0 license, fork it, butcher it, ignore it — your call.

Happy to answer questions about Apps Script production gotchas, Gemini integration patterns, or why I think Sheets-as-database is actually fine for small businesses (until it isn't).

u/Royal-Method-9965 — 3 days ago

Stuck publishing my google sheets add-on to marketplace, need help

I built a small lead gen tool for Google Sheets. It’s pretty simple: you add a list of websites, and it fetches all publicly available emails from those sites.

The tool itself is completed. Descriptions, visuals, landing page and listing content are all ready too.

My problem is getting it published publicly on Google Marketplace. I’ve tried using AI to figure it out, but I’m completely stuck at the Google Cloud / OAuth / integration part. Honestly, it’s confusing as hell and I don’t know how to move forward.

Has anyone here published a Google Sheets Add-on before and can guide me on the process? Especially the Google Cloud setup and what actually needs to be configured to get approved.

reddit.com
u/Danish-M — 2 days ago

Demonstration of Web app work on Google app script for educational purposes. The application consists of up to 20 modules and thousands of lines of code

Added a module for stickers that float above the interface

u/DigPlane7656 — 3 days ago
▲ 17 r/GoogleAppsScript+4 crossposts

How is everyone handling the dreaded Authuser=0 (multiple accounts) bug in Apps Script add-ons?

Hey everyone,

I wanted to open a discussion on handling one of the most notorious and frustrating limitations in Google Apps Script add-on development: the multiple accounts Authuser=0 trap.

The Context: My team recently launched a Workspace management add-on. Shortly after launch, we onboarded an enterprise client who left a great review but immediately reported a frustrating "nitpick": he's logged into multiple Google Workspace accounts, while he's accessing the add-on with his second logged account, the sidebar of our add-on was selecting the default account of their browser rather than the account actually linked to the active spreadsheet.

After consulting with my lead dev, we realised we were dealing with a platform-level infrastructure issue, and not a bug in our code.

The Trap: As most of you know, when a user is juggling multiple Google accounts in one Chrome window (e.g., u/0/, u/1/), Google Apps Script's HtmlService often gets completely confused by the session cookies. If they open the sheet with a secondary account, the underlying iframe still forces the add-on to authenticate using the Default account (authuser=0).

The result is massive user confusion, as the sidebar displays data or permissions for the completely wrong account.

No Workaround Found: We searched high and low but couldn't find a native programmatic patch to force the iframe to respect the active document's user context. So we advised the client to perform their admin operations inside a dedicated Chrome Profile or an Incognito window.

My Questions for the Community: Since we want to provide the smoothest UX possible, I’m curious how other devs here are tackling this:

  1. The "Holy Grail" Fix: Has anyone found a reliable native workaround, undocumented parameter, or JS hack to force HtmlService to respect the active authuser index?
  2. User Experience (UX): Do you preemptively warn users about this in your UI/onboarding flow, or do you just document it in your FAQs and wait for the support tickets to roll in?
  3. Google's Roadmap: Has anyone who talks to Googlers heard any whispers on whether this is ever getting patched at the infrastructure level?

Would love to hear your thoughts, workarounds, and war stories regarding this bug!

reddit.com
u/Plus-Quarter-1459 — 4 days ago

I got tired of paying for time-tracking apps, so I built a free, open-source alternative inside Google Workspace

>Hi everyone,

Like many freelancers and developers, I need to track my hours for different projects. I used to use external SaaS tools, but I realized I was paying for features I didn't need, or worse, adding another subscription to my list when I already live inside Google Workspace all day.

So I built Timesheet, a free and open-source Google Workspace Add-on. It turns your Google Calendar into a full time-tracking environment.

How it works:

  • Native tracking: You just add a #tag to your Google Calendar events (e.g., #project1 Designing the landing page).
  • Built-in Sidebar Timer: It features a clean Material Design 3 sidebar with a real-time start/stop timer. You can even trigger it using the Space bar.
  • One-click Export: It automatically extracts the dates, aggregates hours per project, and formats a clean report into a new Google Sheets tab.
  • Bilingual & Global: The interface switches automatically between English and French. Also, the regex pattern handles full Unicode support, meaning you can use tags in any language like #مشروع or #プロジェクト.
  • HTML Email Reports: You can email the final formatted HTML table to yourself or a client directly from the spreadsheet menu.

The project is licensed under the MIT license, meaning your data stays entirely within your Google account—no external server, no data leaks.

You can find the code and deployment instructions via Clasp here: https://github.com/FabriceFx/gworkspace-timesheet

I would love to get your feedback on this! What features should I add next?

u/FabriceFx — 4 days ago

Rebuilt the UI for my AppsScript tools directory — which one do you actually prefer?

So I've been working on AppsScript Tools for a while now — it's a community directory of extensions, libraries, boilerplates, and dev tooling for Google Apps Script. Started it because I genuinely couldn't find a single place that listed everything useful in one spot.

The site has been live for a while and has thousands of visitors coming every month, which is honestly wild to me. At that point I figured — if people are actually using this thing, it probably deserves a proper UI.

So I did a full redesign. Used Claude to generate the new design — described what I wanted, iterated a few times, and landed on something I genuinely liked. Curious if that shows lol.

Old UI — grid-heavy, icon-focused, clean card layout. Very visual.

New UI — sidebar + editorial layout, think "Product Hunt meets a dev docs site". More metadata (views, stars, timestamps), collections, editor's picks, etc.

My concern with the new one is it might feel too polished for something that's supposed to feel community-built and scrappy. But the old one doesn't scale great as the directory grows.

Curious what you all think — especially if you've visited before. Does the new layout make it easier to find tools, or does it feel like overkill?

Also open to roasting either one lol, I can take it.

u/Razah786 — 4 days ago

Looking to speed up performance with some kind of key-value store

I’m working on a complex spreadsheet with onEdit automations that range from slow to very slow.

I suspect half the problem is repeated fetching from the sheet. Since this data changes very little, I want to use an onOpen function to pre-fetch it and then hold onto it in some kind of data store.

  • Long term, the data lives on the spreadsheet.
  • It’s both structured and unstructured. There isn’t a ton of it. 
  • The sheet only ever has one user at a time.
  • During a typical session of usage, the computer will be put to sleep and woken up repeatedly.

I know frontend frameworks deal with this is a paradigm a lot, but I don’t have any experience with it. What’s the appropriate tool, here—Cache Service, Properties, localStorage, or something else?

reddit.com
u/PhillipLongman — 4 days ago

Where did I go wrong? The two "onEdit" problem.

Ok so im painfully new to javascript and im trying to get two automations going... on the same sheet of course,

The first task sorts the workbook into corresponding sheets and deletes the row as it moves. That one runs fine with the current code.

Im also trying to sort those sheets by multiple columns after the row is moved. Every sheet except one ... The only way ive been able to think to do that is to create a separate task for each of the sheets I need to sort and omit the one I do not.

Of course that ran me smack into the dreaded "multiple onEdit" problem. I was told you can get around it by bundling the tasks into one Onedit "main" and it should run subsequently.

Thing is, it runs the first task, then wont run any of the subsequent. Says "secondtask is undefined" during execution errors.

Ive seen others running with this same work around on youtube so im really not sure why mine doesnt work. I'm sure its a simple fix maybe but I cant seem to find an answer as to why the first task runs but not the second.

I ran it through a javascript validation and it says "parsing error unexpected token const" at line 29 which is

const sheetName = "Colony Maintenance";

Here's the full code, I put some notation in to make it easier to understand what i was trying to do.

Any help would be greatly appreciated!

function onEdit(e) { 
  firstTask(e);
  secondTask(e);
  thirdTask(e); 
  forthTask(e); 
  fifthTask(e); 
  sixthTask(e); 
} 


function firstTask(e) { 
let range = e.range;
let col = range.getColumn();
let row = range.getRow();
let val = range.getValue();
let source = e.source.getActiveSheet();


  if (col == 1 && val !=''){
   let ss = SpreadsheetApp.getActiveSpreadsheet();
   let sheet = ss.getSheetByName (source.getName());
   let targetSheet = ss.getSheetByName(val);
   let data = sheet.getRange(row, 1,1, sheet.getLastColumn()).getValues();


  targetSheet.appendRow(data [0]);
  sheet.deleteRow(row);
  }
 
//this is where the code stops working

function secondTask(e) {    
  //Change to the sheet you want to sort's name
    const sheetName = "Colony Maintenance"; 
    const sheet = e.source.getSheetByName(sheetName);
 
  // Only proceed if the edit happened on the target sheet
  if (e.source.getActiveSheet().getName() !== sheetName) return;

  // Define the range to sort (starting from row 2 to skip headers)
  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());

  // Sort by multiple columns:
  // Priority 1: Column 1 (Ascending= a-z= true)
  // Priority 2: Column 3 (Descending= z-a =false)

  range.sort([
    {column: 11, ascending: true},
    {column: 3, ascending: true},
    {column: 7, ascending: true},
    {column: 6, ascending: true},
    {column: 8, ascending: true},
  ]);
  }

function thirdTask(e) {
    const sheetName = "Veterinary Care"; 
    const sheet = e.source.getSheetByName(sheetName);

  if (e.source.getActiveSheet().getName() !== sheetName) return;

  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());

  range.sort([
    {column: 11, ascending: true},
    {column: 3, ascending: true},
    {column: 7, ascending: true},
    {column: 6, ascending: true},
    {column: 8, ascending: true},
  ]);
  }

function forthTask(e) {
    const sheetName = "Sales"; 
    const sheet = e.source.getSheetByName(sheetName);

  if (e.source.getActiveSheet().getName() !== sheetName) return;

  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());

  range.sort([
    {column: 11, ascending: true},
    {column: 3, ascending: true},
    {column: 7, ascending: true},
    {column: 6, ascending: true},
    {column: 8, ascending: true},
  ]);
  }

function fifthTask(e) { 
    const sheetName = "Breeding"; 
    const sheet = e.source.getSheetByName(sheetName);

  if (e.source.getActiveSheet().getName() !== sheetName) return;

  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());

  range.sort([
    {column: 11, ascending: true},
    {column: 3, ascending: true},
    {column: 7, ascending: true},
    {column: 6, ascending: true},
    {column: 8, ascending: true},
  ]);
  }

function sixthTask(e) { 
    const sheetName = "Home Life"; 
    const sheet = e.source.getSheetByName(sheetName);
 
  if (e.source.getActiveSheet().getName() !== sheetName) return;

  const range = sheet.getRange(2, 1, sheet.getLastRow() - 1, sheet.getLastColumn());

  range.sort([
    {column: 11, ascending: true},
    {column: 3, ascending: true},
    {column: 7, ascending: true},
    {column: 6, ascending: true},
    {column: 8, ascending: true},
  ]);
  }
}
reddit.com
u/DarkArctic88 — 5 days ago

looking for assistance with parsing gmail to a google sheet

Hello, I am really hoping someone can help me parse gmails specifically from Indeed.com, and would like it to pull the date, the Company i applied to, the city and the position i applied to.. I know absolutely nothing about programming. I cant afford all the programs i have found. There will be probably close to 2000 emails i need to have it go through. if someone can help me i would be appreciative.

u/Most-Lingonberry-204 — 4 days ago