Skip to main content
  • For: group admins and trustees
  • You get: a folder in Google Drive or a SharePoint library holding a copy of every Knowledge Base file, in the same folders, refreshed every night
  • Time: about twenty minutes the first time
  • Scopes: files:read
Many groups keep their policies and forms in Scoutworks, but their trustees live in Google Drive or SharePoint. This recipe keeps a copy there, so the documents sit beside the minutes and the accounts, and the group has its own backup. It is a one-way copy: change a document in Scoutworks, and the copy follows that night. A change made to the copy is not sent back, and the next change in Scoutworks overwrites it. Each night it reads only the files that changed since the night before (updatedSince), downloads each one through a link that works for 15 minutes, and saves it. It then reads the full list of files, which is quick, and removes copies of files that were deleted in Scoutworks. The key needs only files:read. It reads every Knowledge Base file whatever its section or sharing, as a group admin does, so keep it as carefully as the documents. Documents on a member’s care plan and premises audit evidence are never included.

1. Try the requests

Paste these into a terminal to see the demo group’s folders and files:
A folder has a name and a parentId, so folders can nest. A file has a name, a folderId (null when it is in no folder), its kind, and virusScan. Copy only files whose kind is upload: a google_drive file is already in Google Drive. To download one, ask for its link:
It answers a url that downloads the file with no key, and works for 15 minutes. Fetch it at once and never store it.

2. Add the script

Go to script.google.com and choose New project. Name it “Scoutworks Knowledge Base copy”. Delete what is there, paste the script below and choose Save.
Code.gs

3. Add your key

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 with files:read.

4. Run it once

Choose copyKnowledgeBase and Run. Google asks you to allow the script to use your Drive and reach an outside service. When it finishes, open Scoutworks Knowledge Base in your Drive: it holds the demo group’s folders and files.The first run copies every file. A group with hundreds of documents may reach Apps Script’s six-minute limit; just run it again. The script remembers each file it has copied, so the next run skips those and carries on with the rest.

5. Run it every night

Choose Triggers (the clock), then Add Trigger: function copyKnowledgeBase, event source Time-driven, Day timer, 2am to 3am.

Switch to your group

Change api-demo.scoutworks.app to api.scoutworks.app, and replace the sandbox key with your own key with files:read. Create it in Settings → Integrations → API keys, and name it “Drive copy” or “SharePoint copy”, so you know which tool to revoke if you stop using it.

Who can see the copy

The copy keeps the files, not their sharing. A document shared only with Beavers leaders in Scoutworks is in the copy for whoever can open the Drive folder or the library. Share the copy only with people who could read every document in Scoutworks: usually the group admins and trustees.

If something goes wrong

  • 409 not_downloadable: the file is a linked Google Drive doc, or the virus scan found something in it. The script skips both.
  • 503 scan_unavailable: a file is still waiting for its virus scan. The script waits and tries again; if it still waits, the file is copied the next night.
  • 429 rate_limited: the key made more than 120 requests in a minute. The script waits and carries on.
  • 403 insufficient_scope: the key has no files:read.
See Errors for every code.