1. Context & Environment
Every UI process runs with a single global object in scope: context. It carries the event that fired the process, the current route, the signed-in user, and the SDK.
console.log(context.router.id); // "84" on /invoices/84
console.log(context.event); // the row or change payload
console.log(context.user?.email);context is always available — there is nothing to import. The event is also bound as a top-level event variable, but prefer context.event.
Context properties
Prop
Type
context.sdk
The SDK is the same surface as the rest of the platform, wrapped so that:
- Reads go through the query cache (
getById/getBySlugreuse in-flight requests). - Writes (
create/update/delete) invalidate that cache automatically. appSlugis filled in from the running app.
await context.sdk.entities.update({
params: { entitySlug: "invoices", recordId: context.router.id },
json: { Status: 2 }
});Groups you will actually use from a UI process:
context.sdk.entities.*— the data planecontext.sdk.applications.runTrigger— run a backend process on demandcontext.sdk.invalidate.entities.*— force a refetch when a write did not go through the SDKcontext.sdk.charts.execute— run a chart's SQL and read{ data: { columns, rows } }
context.sessions
Two sessions exist and must not be mixed.
Prop
Type
context.user is a top-level alias of context.app.user / the app session user. Use it for $user-style identity in process code:
const me = context.user;
if (!me) {
context.toast.error("You are not signed in.");
return;
}Logging
console.log, console.warn, and console.error write to the browser console. UI processes do not have the server log() helper that business processes use. Open DevTools to see output.
console.log("Offer", context.event);
console.error("Create failed", error);