Get your API key

Lesson 4 of 5

An approval page for the manager's phone

A doGet web page with Approve and Reject buttons, the Execute as and access settings, checks that fail safely, and updating without changing the URL.

9 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson the approver will open one link on their phone, see the pending leave requests, and tap Approve or Reject, while the same decide function from lesson 3 does every check.

You need: the app from lesson 3 with decide(row, status, note) working from the menu, your SPEC.md, and a phone signed in to the approver's Google account · Time: 9 minutes

  1. The menu and the button only work in a computer browser. Managers approve leave from their phones, between meetings. An Apps Script web app is a small web page that your script serves: a function called doGet builds the page, and buttons on the page call your script with google.script.run.

    Left, a phone showing a page titled Pending leave requests with two cards: LR-0007 Rahul K., Sick, 2 days, 24 Nov to 25 Nov, fever, doctor visit, with Approve and Reject buttons; and LR-0008 Ayesha S., Earned, 3 days, 1 Dec to 3 Dec. Under the phone: HTML page from doGet, URL ends in /exec. A click arrow goes to a box Script: decide(id, status) with four steps: is this person the approver, is the request still Pending, write status who and when, email the requester; if 1 or 2 fails, stop and change nothing. Arrows lead to Requests tab Status Approved and Email to Rahul.
    The page only shows and asks. The script decides, after its checks.
    Why?

    The page is only a remote control. All the rules stay in decide, so a page bug can at worst show something wrongly; it cannot approve something the rules forbid.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. Decide who runs it and who can open it
  2. Ask the AI for the page, in two pieces
  3. Test it, then deploy it
  4. Try to break it before anyone else does
  5. Recap