Skip to main content
This recipe adds a Members tab to a Google Sheet and fills it from Scoutworks. A timer refreshes it every morning. It takes about five minutes.

1. Add the script

1

Open the script editor

In your Google Sheet, choose Extensions → Apps Script.
2

Paste the script

Delete what is there and paste the script below. Choose Save.
Code.gs
Keep the safe() function. Names on the waiting list come from a public form, so anyone can type one. Without safe(), a name like =IMPORTXML(…) would run as a formula in your sheet.

2. Add your key

1

Open Script Properties

In the script editor, choose Project Settings (the cog), then Script Properties → Add script property.
2

Add the key

Property: SCOUTWORKS_API_KEY. Value: the sandbox key to try it, or your own key. Choose Save script properties.
The key lives in Script Properties, not in a cell. People you share the sheet with cannot see it.

3. Run it

Choose importMembers in the toolbar and press Run. Google asks for permission the first time: it needs to reach an external service and to edit this sheet. Then open the Members tab.

4. Refresh it every morning

1

Add a trigger

In the script editor, choose Triggers (the clock), then Add Trigger.
2

Set the timer

Function: importMembers. Event source: Time-driven. Type: Day timer. Time: 6am to 7am. Choose Save.
If a refresh fails, Google emails you the error. The trigger’s Failure notification settings choose how often.

5. Switch to your group

In the script, change api-demo.scoutworks.app to api.scoutworks.app. In Script Properties, replace the sandbox key with your own. Your key needs the members:read scope.

Read only what changed

The script above reads every member each morning. For a large group, this version reads only the members that changed since the last run. It keeps each member’s id in column A, so it can update or remove that row.
Code.gs
It uses fetchScoutworks() and safe() from the first script. Point the morning trigger at syncMembers in place of importMembers. Each morning it reads only what changed. Once a week it reads every member and rebuilds the tab, which removes members who left and picks up parent links and renames. To force a full read, delete the SCOUTWORKS_MEMBERS_FULL_AT script property. Pagination explains updatedSince and nextUpdatedSince.

Other lists

Change the URL and the columns to read another list: The API reference lists every field.