f365.sp, PnPjs SPFI
Pre-bound PnPjs SharePoint client. Use for arbitrary SP REST calls, lists, libraries, users, groups, search.
f365.sp exposes a pre-configured PnPjs SPFI instance, the canonical JavaScript client
for SharePoint REST. Use it whenever you need to call the SharePoint API from a form: read a related
item, query a library, fetch a user's SP groups, run a search.
Why PnPjs vs f365.http
f365.http is great for your own REST endpoints, but the SharePoint API has quirks PnPjs handles for you:
- Request digests, refreshed automatically on 403
- Batching, coalesce multiple reads into one round-trip
- OData expansion, typed
.select().expand()chains - Response shapes, PnPjs unwraps the SP envelope so you get plain objects
Examples
Read a related item
const item = await f365.sp.web.lists
.getByTitle('Customers')
.items.getById(f365.field('CustomerId').value)
.select('Title', 'AccountManagerId', 'Tier')
.get();
f365.field('AccountManager').value = item.AccountManagerId;
f365.field('Tier').value = item.Tier;
Query with a filter
const active = await f365.sp.web.lists
.getByTitle('Sites')
.items.filter("Status eq 'Active'")
.top(20)
.select('Title', 'Id')
.get();
Update a related item
f365.events.onSave(async ({ itemId }) => {
await f365.sp.web.lists
.getByTitle('Customers')
.items.getById(f365.field('CustomerId').value)
.update({ LastOrderId: itemId });
});
Related
Related articles
- f365.http, typed HTTP client
Get / post / put / delete with JSON parsing. Throws on non-2xx, no need to check response.ok.
- SharePoint column types, overview
Which SharePoint column type binds to which Forms365 component, how values are read and written, and the SP-specific quirks per type.