Skip to main content
  • For: quartermasters, and the leader who orders badges
  • You get: an email every Monday listing what to reorder, and a Deliveries tab that adds what arrives to the stock in Scoutworks
  • Time: about fifteen minutes
  • Scopes: badge-stock:read and uniform:read for the email; badge-stock:write and uniform:write to record deliveries
Running out of Chief Scout’s Silver badges the week before an award night is avoidable. This recipe emails you each Monday with every badge and uniform size at or below its reorder level. A badge counts what young people have already earned but not been given, so you see what you are short of before the award night, not on it. When the order arrives, type it into a Deliveries tab and the sheet adds it to the stock in Scoutworks. Stock is in units. The API never reads or writes a price.
Recording a delivery changes your stock, so the read-only sandbox key can send the email but cannot record a delivery. Use your own key with badge-stock:write and uniform:write, and try one delivery first.

1. Try the requests

A badge’s status is low at or below its reorder level and short when more are owed than are on the shelf. A uniform size is low the same way. See Data definitions.

2. Add the script

In a new 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 the email, or your own key.

4. Send the email every Monday

Choose Run with reorderEmail selected once, and allow it to send email as you. Then choose Triggers (the clock) → Add Trigger: function reorderEmail, event source Time-driven, Week timer, Every Monday.

5. Try one delivery

Reload the sheet. A Scoutworks menu appears. Choose Scoutworks → Record deliveries once: it adds the Deliveries tab. On it, enter one row: a badge’s id from the email (such as badge_123, or a custom badge’s id) or a uniform line’s reorder id (uniform: and its stockId), the section id from the same email line (leave it blank for the central store), how many, and a note. Choose Record deliveries again. The row reads Recorded. Open Badges → Stock or Uniform in Scoutworks and check the count went up. If it was only a test, correct it there. Then enter the real delivery. A row that reads Recorded is never sent again. Each row keeps its own Idempotency-Key in column F, so a retried row is never counted twice. To reuse a row for a new delivery, clear the whole row, column F included.

6. Switch to your group

Change api-demo.scoutworks.app to api.scoutworks.app, and use your own key in Script Properties. For the email alone, your key needs badge-stock:read and uniform:read. To record deliveries, add badge-stock:write and uniform:write.

Variations

  • Correct a stock take. Change type: 'delivery' to type: 'adjustment' and enter a negative number for badges that went missing. Stock never goes below 0: a correction that would answers insufficient_stock.
  • Only one section. Add ?sectionId= and the section’s id to /badge-stock.

If something goes wrong

See Errors for every code. insufficient_stock means the change would take stock below 0. A 400 naming badgeId means that badge is not one you can stock: check its id in GET /badge-catalogue.