1. Add the script
In your Google Sheet, choose Extensions → Apps Script. Delete what is there, paste the script below and choose Save.Code.gs
2. Add your key
In the script editor, choose Project Settings (the cog), then Script Properties → Add script property. Property:SCOUTWORKS_API_KEY. Value: the sandbox key to try it, or your own key.
To send the email to other leaders, add a second property, SEND_TO, with their addresses. Put a comma between them. Without it, the email goes to you.
3. Run it
Choose birthdays in the toolbar and press Run. Open the Birthdays tab. To get the email too, run emailBirthdays once, so Google asks for permission to send email. Then add a trigger: choose Triggers (the clock), then Add Trigger. Function:emailBirthdays. Event source: Time-driven. Type: Month timer. Day: 1st. Choose Save.
4. Switch to your group
Changeapi-demo.scoutworks.app to api.scoutworks.app, and replace the sandbox key with your own. Your key needs members:read and members.contacts:read. The second scope adds dates of birth.
Change it
- One section. Change
readAll('/members')toreadAll('/members?sectionId=…')with the section’sid. Get theidfrom any member in the members list. - Further ahead. Change
DAYS_AHEAD. For example,7gives this week only, for a weekly email. - A birthday on 29 February. In a year with no 29 February, the script shows the birthday on 1 March.