✂️ Snippets
Small, self-contained fragments to copy straight into your solution — each with a two-line intro saying when to reach for it.
Index
rest/
| Snippet | When to reach for it |
|---|---|
| Read all items from a large list — paging done right | Any list past a few thousand items: $top caps at 5,000, $skip is ignored — follow odata.nextLink. Plus the error branch: break returns a partial list that looks complete |
| Find externally / anonymously shared content via Search | Oversharing / Copilot-readiness audit: ViewableByExternalUsers:1 surfaces files shared out, security-trimmed, one query |
| Check another user's effective permissions | Verify what a normal user can actually reach — from your own session, no test account; mind Open = Low bit 16 |
| Upload a generated image as a list item attachment | Canvas charts, placeholder banners, QR codes — AttachmentFiles/add takes a raw ArrayBuffer; the item must exist first |
| Write to Azure Table Storage without the SDK (SharedKeyLite) | Telemetry/counters from an Azure Function without @azure/data-tables bloat — Table-flavored SharedKeyLite signing, first-= connection-string parsing, 409 = fine |
| Resolve a pasted library URL (web, library, folder) | SP.Web.GetWebUrlFromPageUrl, called on the CURRENT web, resolves the web of any URL in the tenant (other site collections too, 404 for a missing site); strip Forms/…aspx, prefer the ?id= folder, take the first segment under the web as the library, check BaseTemplate 101 — all measured from the browser |
cli/
| Snippet | When to reach for it |
|---|---|
| SPO Management Shell one-liners | Quick admin answers — storage top 20, external sharing, deleted sites, lock state — no script file needed |
Planned categories
caml/ (CAML query building blocks) · list-formatting/ (column and view formatting JSON)
Saved you an hour? A star on GitHub helps other SharePoint people find the vault.★ Star on GitHub