Interactive Workspace Sidebar
Editing rows directly can be awkward for nontechnical users.
What this teaches
Build a form inside Sheets. Intake forms, help requests and simple trackers.
Start without an account in the local application. Read/edit the input, predict a result, run the current source and verify output. A local document preview is not a real Google Doc; a fixture is not a live model response.
Input and expected result
Input tab: Requests. Entry function: showSidebar().
| Request | Category | Status |
|---|---|---|
| Replace monitor | IT | Open |
| Book room | Facilities | Open |
Expected baseline: Submitting Test request / IT adds exactly one Open row.
Exact Workspace setup
- Download and unzip this project. Use one separate bound script per lesson.
- Create a dedicated Drive folder. Create a native Google Sheet inside it, and import starter.csv into a tab named Requests. Check the exact headers above.
- Open the Sheet → Extensions → Apps Script. Paste finished Code.gs into the script editor. Save.
- Use + → HTML, name it Sidebar and paste Sidebar.html.
- Choose showSidebar in the function selector → Run. Review actual requested permissions. Reload the Sheet for the Workshop menu.
- Compare output with the baseline above. Check generated documents/drafts manually. No email should be sent.
- Perform the original challenge, investigate a failure and test duplicate/partial runs before scheduling. Do not install a trigger just because one manual run succeeded.
Understand the implementation
HTML Service opens the sidebar; addRequest validates and appends the row.
Key operations: HtmlService.createHtmlOutputFromFile(); showSidebar(); google.script.run; appendRow()
Focused source spotlight
This is an excerpt, not a standalone script. The complete implementation follows.
function showSidebar(){
// HTML Service renders a form inside the spreadsheet.
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile('Sidebar').setTitle('New request'));
}Complete Code.gs
// Interactive Workspace Sidebar
// Entry point: showSidebar; source data stays intact unless explicitly noted.
function onOpen(){SpreadsheetApp.getUi().createMenu("Workshop").addItem("Run application","showSidebar").addToUi();}
function showSidebar(){
// HTML Service renders a form inside the spreadsheet.
SpreadsheetApp.getUi().showSidebar(HtmlService.createHtmlOutputFromFile('Sidebar').setTitle('New request'));
}
// Server validates submitted values before appending a record.
function addRequest(request,category){request=String(request).trim();if(!request||!['IT','Training','Other'].includes(category))throw Error('Invalid request');SpreadsheetApp.getActive().getSheetByName('Requests').appendRow([/^[=+@-]/.test(request)?"'"+request:request,category,'Open']);return 'Saved';}
Complete Sidebar.html
<!doctype html><html><body><form id="f"><input id="request" required placeholder="Request"><select id="category"><option>IT</option><option>Training</option><option>Other</option></select><button id="submit">Save</button></form><p id="status"></p><script>document.getElementById('f').onsubmit=e=>{e.preventDefault();const b=document.getElementById('submit'),s=document.getElementById('status');b.disabled=true;google.script.run.withSuccessHandler(v=>{s.textContent=v;b.disabled=false;e.target.reset()}).withFailureHandler(err=>{s.textContent=err.message;b.disabled=false}).addRequest(document.getElementById('request').value,document.getElementById('category').value)};</script></body></html>Four guided activities
Discover and run
Editing rows directly can be awkward for nontechnical users.
- Inspect the editable Requests table. The starter has 2 records.
- Write your predicted result in Prediction. Click Run application.
- Compare Output with: Submitting Test request / IT adds exactly one Open row.
- Click Verify baseline; explain one result in Notes.
Expected: Submitting Test request / IT adds exactly one Open row.
Understand and modify
Submit an empty request; expect rejection; submit Test request / IT; expect one row.
- Open Source and read showSidebar. Select the entry function in the walkthrough.
- Return to Application. Click Prepare original challenge to create a separate challenge starting state.
- For AI projects inspect the revised recorded fixture: this is supplied response data, not newly generated AI.
- Run application and use Verify challenge; approval/sidebar projects show extra required steps.
Expected: Submit an empty request; expect rejection; submit Test request / IT; expect one row.
Investigate and repair
Empty sidebar request
- Save a snapshot if you want to keep your experiment.
- Click Inject investigation. Submit spaces only in the sidebar form.
- Run application and inspect Output and Execution trace. Some investigations produce wrong/stale content rather than exceptions.
- Repair it: Type Test request and choose IT, then Submit request. Run again and explain the root cause.
Expected: Server validation must run even when browser required validation exists.
Extend and automate
Add status filtering and refresh without closing sidebar.
- Open Prompts. Select Extend and adapt the requirement to your goal.
- Build the feature in Source or export the complete project to Apps Script.
- Retest baseline and original challenge before considering scheduling.
- Use Resources → Automation readiness. Use a form-submit integration for unattended intake; sidebar itself needs user interaction.
Expected: The baseline still works; independent extension checks are designed and reviewed by you.
Original exercise
Submit an empty request; expect rejection; submit Test request / IT; expect one row.
Debugging and troubleshooting
Empty sidebar request
Submit spaces only in the sidebar form.
Hint 1
Check the exact input/response contract and identify the affected field.
Hint 2
HTML Service opens the sidebar; addRequest validates and appends the row.
Hint 3 and repair
Type Test request and choose IT, then Submit request.
Server validation must run even when browser required validation exists.
Missing tab: check its exact name. Missing document: ensure unique native companion Docs share the Sheet’s dedicated folder. Authorization failure: review source and contact your administrator. Recorded response exhausted: add a new explicit fixture; no live AI is running. Invalid JSON: repair syntax before validating schema. Valid but unsupported content: compare each claim with source records.
Build prompt
Act as a Google Apps Script tutor. Build a container-bound Sheets app for lesson 14: Interactive Workspace Sidebar. Input tab Requests, exact headers: Request, Category, Status. Create Code.gs and Sidebar.html; onOpen menu opens sidebar; form collects request and category, validates on server and appends Open row; use success/failure handlers and disable submit while pending. 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: Submitting Test request / IT adds exactly one Open row. 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 showSidebar and its output behavior. Reference: https://github.com/lsvekis/Google-Apps-Script-Workshop/tree/main/14-interactive-workspace-sidebar. Base version limitations: Existing Facilities sample is not an allowed new category; use IT, Training or Other.
Extension prompt
Update the existing app without removing working features. Add status filtering and refresh without closing sidebar. Return complete updated files, explain changes and give regression tests. Automation option: Use a form-submit integration for unattended intake; sidebar itself needs user interaction. Keep this separate from the baseline exercise.
Knowledge check and answer key
- Which input tab does showSidebar read?
Answer
Requests
- Which function starts the original application?
Answer
showSidebar
- What is the baseline output you must verify?
Answer
Submitting Test request / IT adds exactly one Open row.
- Does this project need runtime Gemini in the real Workspace baseline?
Answer
No; Gemini can help during development only.
- What limitation matters before scheduling?
Answer
Existing Facilities sample is not an allowed new category; use IT, Training or Other.
Safe automation
Use a form-submit integration for unattended intake; sidebar itself needs user interaction.
Existing Facilities sample is not an allowed new category; use IT, Training or Other.
Reflect and extend
Explain the transformation using one actual input row. Which incorrect value could still pass structural validation? What happens if the function runs twice or fails after creating one output? Write your explanation before building this extension: Add status filtering and refresh without closing sidebar.
Source alignment
Physical slide 35; printed sequence 26 of 48. Reference source SHA-256 5d9d66b79325ed1d6bfbe55f93c492835857a13ef4ec6ab28d55f510a243238e.
Slide notes use Workshop Info B2. Verified repository resolves the active spreadsheet parent folder; this build follows the repository. Keep companion files in that dedicated lesson folder.
Pinned repository reference · Full source manifest
Five-minute presenter demonstration
0:00–0:45
Action: Open Input. Read Requests headers and first row.
Editing rows directly can be awkward for nontechnical users. This application is useful for Intake forms, help requests and simple trackers. We will run the verified reference code against fictional data.
0:45–1:30
Action: Ask for predictions. Click Run application, then Verify baseline.
Our baseline is Submitting Test request / IT adds exactly one Open row. The browser displays local results. It has not connected to Google or a model.
1:30–3:00
Action: Open Source. Select showSidebar in the code walkthrough.
HTML Service opens the sidebar; addRequest validates and appends the row. The complete code is available to edit and download. The excerpt is not a standalone script.
3:00–4:15
Action: Click Prepare original challenge, inspect the changed inputs, and Run application. Complete extra review/sidebar steps if listed.
Submit an empty request; expect rejection; submit Test request / IT; expect one row. For AI lessons we edit a recorded response as well as source data. That response must be checked, not trusted.
4:15–5:00
Action: Click Verify challenge. Open Guide and read Automation considerations.
The important limitation is: Existing Facilities sample is not an allowed new category; use IT, Training or Other. Before scheduling: Use a form-submit integration for unattended intake; sidebar itself needs user interaction. Explain the result yourself before moving on.