Autorun AI Docs

UI Functions Reference

UI functions are the browser-side library available inside every UI process. Data hangs off context.sdk. Everything that touches the screen hangs off namespaced helpers on context.

const created = await context.sdk.entities.create({
  params: { entitySlug: "invoices" },
  json: { ClientName: "Acme Corp", Amount: 1500 }
});

context.toast.success("Invoice " + created.id + " created.");
Process code written for the previous frontend will not run

The old helpers — createEntity, getEntity, getEntities, updateEntity, deleteEntity, updateComponentByName, downloadPDF, mutate, and the rest — no longer exist, and there is no compatibility layer. Calling one fails at runtime with "is not a function". See Coming from the previous frontend at the end of this page.


Three rules that apply everywhere

SDK calls are asynchronous. Always await context.sdk.*. Toast, modal, redirect, and context.component.* are synchronous.

Do not pass appSlug. context.sdk injects the running app. A hardcoded slug breaks the moment the app is copied under a new name.

Hooks are illegal. sdkClient and React hooks cannot run inside process code. Use the imperative context.sdk (Promise-based, cache-aware).


Quick Reference


Every function at a glance

Data — context.sdk.entities

FunctionReturns
getById({ params: { entitySlug, recordId } })the record (often on .data)
getBySlug({ params: { entitySlug }, query? }){ data, totalCount, rowCount }
create({ params: { entitySlug }, json }){ success, id, message }
update({ params: { entitySlug, recordId }, json }){ success, id, message }
delete({ params: { entitySlug, recordId } }){ success, id, message }

Writes auto-invalidate the entity cache. You do not call a separate mutate helper.

UI control

FunctionReturns
context.component.getByName(name)the component
context.component.getPropByName(name, prop)the prop value
context.component.updateByName(name, prop, value)void
context.component.updateByKey(key, prop, value)void
context.component.updateState(name, prop, value)void
context.toast.success / error / info / warning(message)void
context.modal.confirm / info / warning / error / success(config)modal handle
context.redirect(url)void

Documents — context.document

FunctionReturns
pdf(entitySlug, recordId, templateId, fileName?, footer?, header?)Promise<void>
pdfWithBarCode(entitySlug, recordId, templateId, barCode, ...)Promise<void>
word(entitySlug, recordId, templateId, fileName?)Promise<void>
excel(payload, templateId, fileName)Promise<void>
file(url, payload, fileName)Promise<void>

Backend processes — context.sdk.applications

FunctionReturns
runTrigger({ params: { triggerId }, json }){ success, result, error, ... }

triggerId is the trigger's file basename, not a numeric id.


Records

Records are flat objects keyed by column name in PascalCase. Lookup fields arrive expanded as objects rather than as bare foreign keys.

{
  "ID": 84,
  "ClientName": "Acme Corp",
  "Amount": 1500.00,
  "CreateDate": "2026-03-12T10:24:00.000Z",
  "CreateUser": { "ID": 7, "FullName": "John Smith" },
  "SystemStatusID": { "ID": 1, "Name": "Active" }
}

When building a create or update payload, pass the lookup's .ID (a number), not the expanded object.


Coming from the previous frontend

Every helper below was part of the original UI process API and has been removed. There is no shim — a call to any of them throws.

PreviousNow
context.createEntity(slug, payload)context.sdk.entities.create({ params: { entitySlug: slug }, json: payload })
context.getEntity(slug, id)context.sdk.entities.getById({ params: { entitySlug: slug, recordId: id } })
context.getEntities(slug, queryString)context.sdk.entities.getBySlug({ params: { entitySlug: slug }, query })
context.updateEntity(slug, id, payload)context.sdk.entities.update({ params: { entitySlug: slug, recordId: id }, json: payload })
context.deleteEntity(slug, id)context.sdk.entities.delete({ params: { entitySlug: slug, recordId: id } })
result.values[0] / result.valuesresult.data (list) or result.data ?? result (one record)
context.updateComponentByName(...)context.component.updateByName(...)
context.getComponentByName(...)context.component.getByName(...)
context.getComponentPropByName(...)context.component.getPropByName(...)
context.updateComponentByKey(...)context.component.updateByKey(...)
context.updateComponentState(...)context.component.updateState(...)
context.downloadPDF(...)context.document.pdf(...)
context.downloadPDFWithBarCode(...)context.document.pdfWithBarCode(...)
context.downloadWord(...)context.document.word(...)
context.downloadExcel(...)context.document.excel(...)
context.downloadFile(...)context.document.file(...)
context.mutate(slug)automatic on SDK writes, or context.sdk.invalidate.entities.getBySlug({ entitySlug: slug })
context.clearEntityCache()context.sdk.invalidate.entities.all()
context.state.foo = valuecontext.appState.set("foo", value) / .get("foo")
context.primaryColorcontext.app.primaryColor
context.apiClient.post("/Trigger?id=N", body)context.sdk.applications.runTrigger({ params: { triggerId: "filename" }, json: body })
Two more things that changed quietly

create returns { success, id, message } — not the saved row. And id is lowercase; every record field everywhere else is uppercase ID.