Apps Script example · 12 min read

Track FDA Deadlines with Working Days: Copy-Paste Apps Script Pattern

Working track fda deadlines with working days example in Apps Script—copy-paste code, common mistakes, and when to get it built professionally.

MailAppTime-drivenFDA

Countdown working days to FDA/agency deadlines and email owners for due-soon or overdue items. The workbook becomes the system of record; Apps Script owns the joins and business rules so analysts are not pasting monthly formulas.

Entry point `trackFdaDeadlines` reads typed columns with SpreadsheetApp batch APIs. MailApp is the primary service; Time-driven describes how you usually invoke it after authorization.

Keep thresholds (grace days, bands, alert emails, API keys) in Config cells or Script Properties so the same .gs file promotes from sandbox to production without code edits.

This page is technical only: sheet layout, edge cases, runnable code, deploy steps, and FAQs for track fda deadlines with working days. No consulting pitch—just the pattern you can paste and harden.

Need this built? Hire a Google Apps Script developer →

Sheet / project setup

TabColumnsNotes
DeadlinesItem, Agency, Due, Owner, StatusSource
FdaTrackCountdownOutput

What this script does

trackFdaDeadlines() countdown working days to FDA/agency deadlines and email owners for due-soon or overdue items.

  • Working-day math
  • DUE_SOON≤5
  • Owner emails

Prerequisites

Container-bound script on the workbook that contains the tabs in the setup table. Authorize MailApp scopes on first run.

  • V8 runtime
  • Exact sheet names
  • Script timezone = ops timezone

Walkthrough

Working-day countdown skipping weekends; escalate DUE_SOON (≤5) and OVERDUE via MailApp.

Paste the code, set Config/Properties, run trackFdaDeadlines once, verify the output tab, then attach a Time-driven trigger.

Edge cases

DONE rows are omitted from FdaTrack so the board stays action-oriented.

Testing

Use a sandbox copy with 3–5 known rows. Compute expected outputs for track fda deadlines with working days offline, run trackFdaDeadlines, and diff the output tab including one intentional bad row.

Hardening

Add LockService around multi-sheet writes if triggers can overlap. Log run timestamps. Keep API keys and alert emails in PropertiesService—not in shared cells.

Variations

Fork ideas: filter to one business unit, change grain (daily→weekly), or POST a summary payload after trackFdaDeadlines succeeds.

Operations notes

Assign an owner for the output tab, document regenerate steps, and treat `trackFdaDeadlines` as source of truth over ad-hoc cell formulas.

Full code: trackFdaDeadlines()

Run trackFdaDeadlines when source tabs are current. Edit sheet names and Config/Properties first.

function workingDaysBetween_(a,b){
  let n=0; const d=new Date(a);
  while(d<b){ const day=d.getDay(); if(day!==0&&day!==6) n++; d.setDate(d.getDate()+1); }
  return n;
}
function trackFdaDeadlines(){
  const ss=SpreadsheetApp.getActive();
  const today=new Date();
  const rows=ss.getSheetByName('Deadlines').getDataRange().getValues().slice(1);
  const out=[];
  const escalate=[];
  rows.forEach(r=>{
    if(String(r[4]).toUpperCase()==='DONE') return;
    const due=new Date(r[2]);
    const wd=workingDaysBetween_(today,due);
    const status=wd<0?'OVERDUE': wd<=5?'DUE_SOON':'OK';
    out.push([r[0],r[1],due,wd,status,r[3]]);
    if(status!=='OK') escalate.push(r[3]+': '+r[0]+' '+status+' ('+wd+' wd)');
  });
  const sh=ss.getSheetByName('FdaTrack');
  sh.clearContents();
  sh.appendRow(['Item','Agency','Due','WorkingDays','Status','Owner']);
  if(out.length) sh.getRange(2,1,out.length+1,6).setValues(out);
  if(escalate.length){
    const email=PropertiesService.getScriptProperties().getProperty('REG_ALERT');
    if(email) MailApp.sendEmail(email,'FDA deadline alert', escalate.join('\\n'));
  }
}
  1. Line 6: Entry point — bind triggers to trackFdaDeadlines.
  2. Line 9: Batch read; avoid per-cell getValue in loops.
  3. Line 23: Batch write output rows in one setValues call.
  4. Line 25: Script Properties for thresholds/secrets.
  5. Line 26: Digest email; authorize mail scopes once.

Deploy this example

  1. 01

    Open Apps Script

    In the bound spreadsheet: Extensions → Apps Script. For standalone projects, create one at script.google.com and link your Sheet by ID.

  2. 02

    Paste and save

    Add a .gs file, paste the code below, rename constants at the top (sheet names, column letters, API property keys), then save.

  3. 03

    Authorize once

    Run the main function from the editor. Accept OAuth scopes when prompted — triggers cannot run until authorization succeeds once.

  4. 04

    Add the trigger

    Triggers → Add trigger → choose the handler function and event (time-driven, on edit, or on form submit). Delete test triggers before production.

Before you run: track fda deadlines with working days

  • 1Setup tabs exist with headers matching trackFdaDeadlines
  • 2Dry-run on a copy workbook
  • 3Timezone verified
  • 4MailApp authorization completed
  • 5Output spot-checked against hand calc
  • 6Time-driven trigger added only after validation
  • 7Owners + alert recipients documented

Frequently asked questions

At minimum the tabs listed in the setup table for Track FDA Deadlines with Working Days. Output tabs may be cleared each run—do not store source-of-truth data there.

Run from the Apps Script editor for dry runs. Production usually uses a Time-driven trigger after OAuth succeeds once.

DONE rows are omitted from FdaTrack so the board stays action-oriented.

Per-cell calls burn quota and wall time. One read + one write keeps this pattern under the 6-minute execution cap longer.

PropertiesService (Script Properties) for API keys and alert inboxes. Config sheet is fine for non-secret thresholds.

Simple ratios maybe; track fda deadlines with working days needs joins, branching, or side effects (email/Docs/API) that Apps Script handles cleanly.

Keep the .gs in clasp/git. Avoid divergent copies of formulas on the output tab—regenerate from the script.

Related examples

Want this wired into your real workflow?

I adapt these patterns to your Sheet structure, APIs, and triggers — deployed in your Google account. Fixed-scope quotes from $500 · free 30-min consult · quote within 24 hours.