- For: treasurers
- You get: an Uncategorised tab with a category dropdown on each line, and a menu command that saves your choices
- Time: about fifteen minutes the first time
- Scopes:
accounting:read,accounting.people:readandaccounting:write
1. Try the requests
The sheet uses two lists. Paste these into a terminal to see them for the demo group:"categoryId": null. A line split across several categories has its categories on its splits, so the script leaves split lines alone.
2. Add the script
In your Google Sheet, choose Extensions → Apps Script. 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 loading, or your own key.
4. Load the lines
Reload the sheet. A Scoutworks menu appears. Choose Scoutworks → Load uncategorised lines. The first time, Google asks you to allow the script to reach an outside service. Each row is one line from this accounting year with no category. Money in offers income categories, and money out offers spending categories. Sort and filter the tab however helps: by who was paid, say, so you can fill a run of rows at once.5. Try it on one row
Before you save many rows, check that one saves as you expect.1
Choose one category
Choose a category on one row only.
2
Save it
Choose Scoutworks → Save categories. The row says Saved.
3
Check it in Scoutworks
Find that line in Scoutworks. It shows the category you chose, and nothing else about it has changed. If it is not what you meant, change it back there.
6. Save your choices
Choose a category on as many rows as you like, then Scoutworks → Save categories. Each row says Saved or why it was not. Rows you left blank are not touched. Run Load uncategorised lines again to start afresh with what is left.7. Switch to your group
Changeapi-demo.scoutworks.app to api.scoutworks.app, and replace the sandbox key with your own. The key needs:
accounting:readto read the lines and categories;accounting.people:readto show each line’s description and who it was paid to or by. Without it, those columns are empty;accounting:writeto save.
Safe to use alongside the app
Each row remembers the line’supdatedAt from when you loaded it. If someone changes the line in Scoutworks before you save, the save for that row is refused with 412 stale_write, and the row says so. Nobody’s change is overwritten. Load again to see the line as it is now. Writing data explains how this works for every record.
The script changes only the category. The amount, date and description stay exactly as the bank or the treasurer recorded them.
If something goes wrong
412 stale_write: the line changed after you loaded it. Load again.409 period_closed: the line is in a closed accounting year, which cannot change.403 insufficient_scope: the key cannot write. Addaccounting:write, or use your own key in place of the sandbox key.