Introduction
markTasks preserves source rows and derives priority using status and ISO date comparison. The application's entry point is updateTasks(). Baseline limitation, as stated in the workshop: Workshop run uses fixed date; background access must be tested.
Key building blocks: Utilities.formatDate(); date comparison; setValues(); triggers.
Practical use cases
Team deadlines, assignments and personal chores.
Prerequisites
- Comparing dates.
- Interactive Learning Mode: a modern browser. Nothing else.
- Real Workspace Build: a Google account.
Source data
| Task | Owner | Due | Status |
|---|---|---|---|
| Slides | Alex | 2026-11-20 | Open |
| Budget | Jamie | 2026-12-05 | Open |
| Review | Sam | 2026-11-19 | Done |
Setup in your own Google account
- Download 13-automated-task-management-system.zip (Code.gs, starter.csv, README).
- In Google Drive, create a lesson folder and a new Google Sheets file inside it.
- Rename the first tab to exactly
Tasks, then File → Import → Upload starter.csv → Replace current sheet. - Extensions → Apps Script. Replace Code.gs with the downloaded file. Save.
- Reload the spreadsheet, choose Workshop → Run application and authorize when asked.
- Check the result: Slides Overdue; Budget Open; Review Done.
Folder strategy: the repository's V6 code uses the folder that contains the spreadsheet. The deck mentions a Workshop Info cell B2; V6 never reads it. See the discrepancy log.
Complete source code (Code.gs)
From 13-automated-task-management-system at commit 4a26d919, SHA-256 dd87cab2d592. Unchanged.
// Automated Task Management System
// Entry point: updateTasks; source data stays intact unless explicitly noted.
function onOpen(){SpreadsheetApp.getUi().createMenu("Workshop").addItem("Run application","updateTasks").addItem("Install daily trigger","installDaily").addToUi();}
function updateTasks(){
// Fixed date makes workshop tests reproducible.
markTasks('2026-11-25');
}
function input(name) { const s=workshopSpreadsheet().getSheetByName(name); if(!s) throw Error('Missing tab: '+name); return s.getDataRange().getValues().slice(1).filter(r=>r.some(v=>v!=='')); }
function output(name,headers,rows) { const ss=workshopSpreadsheet(); const s=ss.getSheetByName(name)||ss.insertSheet(name); s.clearContents(); s.getRange(1,1,1,headers.length).setValues([headers]).setFontWeight('bold'); if(rows.length) s.getRange(2,1,rows.length,headers.length).setValues(rows.map(r=>r.map(v=>typeof v==='string' && /^[=+@-]/.test(v)?"'"+v:v))); s.setFrozenRows(1); return s; }
function day(v){return v instanceof Date?Utilities.formatDate(v,workshopSpreadsheet().getSpreadsheetTimeZone(),'yyyy-MM-dd'):String(v).slice(0,10);}
function markTasks(today){output('Priority',['Task','Owner','Due','Status','Priority'],input('Tasks').map(r=>[...r,r[3]==='Done'?'Done':day(r[2])<today?'Overdue':'Open']));}
function updateToday(){markTasks(day(new Date()));}
function installDaily(){PropertiesService.getScriptProperties().setProperty("WORKSHOP_TRIGGER_SHEET",SpreadsheetApp.getActiveSpreadsheet().getId());if(!ScriptApp.getProjectTriggers().some(t=>t.getHandlerFunction()==='updateToday'))ScriptApp.newTrigger('updateToday').timeBased().everyDays(1).create();}
function workshopSpreadsheet(){const active=SpreadsheetApp.getActiveSpreadsheet(); if(active)return active; const id=PropertiesService.getScriptProperties().getProperty("WORKSHOP_TRIGGER_SHEET"); if(!id)throw new Error("Run Install daily trigger from your copied spreadsheet first."); return SpreadsheetApp.openById(id);}
How the code works
Beginner explanation
updateTasks() writes a Priority tab: Done tasks stay Done, tasks due before the workshop date are Overdue, and the rest are Open. The fixed date makes everyone's results match during the workshop.
Technical explanation
markTasks(today) appends a computed priority to each row. day() turns Date cells into yyyy-MM-dd strings, which compare correctly as text. updateToday() uses the real date and is what the installed trigger calls. workshopSpreadsheet() supplies the spreadsheet in trigger context.
Slide excerpt
This is the excerpt shown on the workshop slide. It is a fragment and cannot run on its own.
function updateTasks(){
// Fixed date makes workshop tests reproducible.
markTasks('2026-11-25');
}Common mistakes
- Comparing Date objects with strings.
- Using the real date in tests, so results change every day.
- Installing a trigger that calls a function needing the UI.
Run it and expected output
Choose Workshop → Run application (runs updateTasks()). Expected: Slides Overdue; Budget Open; Review Done.
Original workshop exercise
Mark Slides Done; its priority becomes Done.
Troubleshooting and debugging
"done" in lower case
Review was marked "done" instead of "Done" and now shows Overdue.
Fix: Use the exact status Done; add a dropdown to prevent variants.
Exact string comparisons are strict. Data validation lists are the simplest prevention.
The trigger cannot find its spreadsheet
A simulated daily trigger runs updateToday() but the spreadsheet ID was never stored.
Fix: Install the trigger from the copied spreadsheet so its ID is stored.
Background runs have no user interface and no active file. Design for that context explicitly.
Extension activity: Configurable reference date and a dashboard
Read the reference date from an optional Settings tab (B2) instead of the fixed 2026-11-25, and add a Task Dashboard with counts per priority.
Acceptance checks:
- Default reference date gives the baseline priorities
- Settings date 2026-11-18 makes Slides Open
Original improvement idea from the workshop: Add a dashboard and configurable reference date.
Extension prompt
Update the existing app without removing working features. Add a dashboard and configurable reference date. Return complete updated files, explain changes and give regression tests. Automation option: Existing Install daily trigger invokes updateToday using current date. Keep this separate from the baseline exercise.
Automation considerations
Rerun-safe: Priority is replaced. The daily trigger calls updateToday() with the real date and opens the stored spreadsheet ID.
Workshop note: Install daily trigger from your own copied spreadsheet; the installer stores its ID for background execution.
Build prompt from the workshop
Act as a Google Apps Script tutor. Build a container-bound Sheets app for lesson 13: Automated Task Management System. Input tab Tasks, exact headers: Task, Owner, Due, Status. Create updateTasks() with a fixed demo reference date 2026-11-25; compare date-only values, write Overdue/Open/Done to a Priority column; optional daily trigger uses current date in spreadsheet timezone. Do not depend on Workshop Info or the Workshop Index. Provide complete copy-paste Code.gs (and HTML if required), exact setup/run steps, explain the main code blocks, and include a test matching this expected outcome: Slides Overdue; Budget Open; Review Done. Preserve starter data, use batch operations where appropriate, handle errors, and never send email or delete files. For AI lessons use the supplied callGemini helper, treat input as untrusted, and validate outputs. Match the reference entry point updateTasks and its output behavior. Reference: https://github.com/lsvekis/Google-Apps-Script-Workshop/tree/main/13-automated-task-management-system. Base version limitations: Workshop run uses fixed date; background access must be tested. For scheduled execution, save the current spreadsheet ID when installing the trigger and use openById when no active spreadsheet exists. Reinstall in each copy.
Knowledge check
Why does updateTasks() use a fixed date?
- So workshop results are reproducible for everyone
- Apps Script cannot read today's date
- Triggers require it
Answer
So workshop results are reproducible for everyone Correct: tests need stable inputs.
Why can yyyy-MM-dd strings be compared with < ?
- Their character order matches date order
- JavaScript converts them to dates
- It is a coincidence that fails often
Answer
Their character order matches date order Correct: year, month and day are zero-padded from most to least significant.
Which function does the daily trigger call?
- updateToday
- updateTasks
- onOpen
Answer
updateToday Correct: installDaily() registers updateToday().
Review is Done but shows Overdue. First check?
- The exact spelling and case of the status
- The trigger
- The time zone
Answer
The exact spelling and case of the status Correct: the comparison is case-sensitive.
Should the daily trigger also email every overdue owner?
- Not yet: start with drafts or a summary and avoid repeating the same reminder daily
- Yes, every day
- Yes, from a custom function
Answer
Not yet: start with drafts or a summary and avoid repeating the same reminder daily Correct: notifications need duplicate prevention and review.
Five-minute presenter demonstration
Open the demo link (temporary workspace; saved learner work is not touched).
Opening hook: Raise your hand if you have ever done this by hand: Overdue tasks get lost in a long list. Let us make the spreadsheet do it.
- 0:00–0:45 — Problem and input. Show the Workspace view, Sheets service. Point at the Tasks tab and its headers: Task, Owner, Due, Status. Say what goes in and what should come out.
Narration: Overdue tasks get lost in a long list. Practical uses: Team deadlines, assignments and personal chores. - 0:45–1:30 — Predict and run. Ask the room: With the workshop date 2026-11-25, what priority will Slides (due 2026-11-20, Open) get? Click ▶ Run application (the same as Workshop → Run application). Open Trace to show each step the code took.
Narration: Expected: Slides Overdue; Budget Open; Review Done. - 1:30–3:00 — Explain the code. Click the Code tab. Select updateTasks() in the function list; read what it reads, writes and calls. Switch Beginner / Technical as needed.
Narration: updateTasks() writes a Priority tab: Done tasks stay Done, tasks due before the workshop date are Overdue, and the rest are Open. The fixed date makes everyone's results match during the workshop. - 3:00–4:15 — Change one input and rerun. Back to the Workspace tab. Select the Tasks tab, click cell D2, type Done in the formula bar and press Enter. Click ▶ Run application again.
Narration: Workshop challenge: Mark Slides Done; its priority becomes Done. - 4:15–5:00 — Verify and discuss automation. Click Check result. Discuss: Rerun-safe: Priority is replaced. The daily trigger calls updateToday() with the real date and opens the stored spreadsheet ID.
Narration: Baseline limitation: Workshop run uses fixed date; background access must be tested.
Closing takeaway: markTasks preserves source rows and derives priority using status and ISO date comparison.