Business Functions Reference
Business functions are the server-side library available inside every business process. They all hang off context.functions:
const result = await context.functions.create("invoices", { ClientName: "Acme Corp", Amount: 1500 });The old function names — CreateRecord, GetRecord, SendNotificationAsync, SendHttpRequestAsync, CallAIAsync 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 backend at the end of this page.
Three rules that apply everywhere
Every function is asynchronous. There are no synchronous variants of anything. Always await, including in loops.
The Async suffix means nothing. SendEmailAsync and create are equally asynchronous. Some names carry the suffix for historical reasons and some do not — there is no SendEmail to pair with SendEmailAsync.
Names are case-sensitive and inconsistent. Data functions are lower camel case (create, getById, generatePdf); messaging functions are PascalCase (Notify, SendEmailAsync). Copy them exactly.
Quick Reference
Context & Environment
The context object, records, claims and variables
Create Record
Insert a single record
Get Record
Read records with filters, sorting and paging
Update Record
Partial updates to a single record
Delete Record
Delete a single record
Bulk Operations
Create, update and delete many records at once
Sequences
Atomic counters for invoice and order numbers
Notifications
In-app alerts for a user, a group, or everyone
Send email from a process
SMS & WhatsApp
Send text and messaging app notifications
Frontend Execution
Push UI actions to connected sessions
Document Generation
Generate PDF, Word and Excel files
Excel Templates
Fill templates and work with XLSX directly
Files
Read stored file contents
HTTP Requests
Call external APIs
AI Integration
Prompt an agent from a process
Error Handling
Failure modes, validation and timeouts
Every function at a glance
Data
| Function | Returns |
|---|---|
get(slug, options?) | { records, totalCount, rowCount } |
getById(slug, id) | the record, or null |
create(slug, values) | { success, id, message } |
update(slug, id, values) | { success, message } |
delete(slug, id) | { success, message } |
createBulk(slug, records, options?) | bulk result |
updateBulk(slug, records, options?) | bulk result |
deleteBulk(slug, idsOrOptions, options?) | bulk result |
Messaging
| Function | Returns |
|---|---|
Notify(userId, title, content, link, type) | boolean |
NotifyGroup(field, operator, value, title, content, link, type) | boolean |
BroadcastAsync(title, content, link?, type?) | boolean |
SendEmailAsync(to, subject, body, from) | boolean |
SMSNotifyAsync(phone, message) | delivery result |
WhatsAppNotifyAsync(phone, message) | delivery result |
SendFunctionToUserAsync(userId, functionId, payload?) | always true |
BroadcastFunctionAsync(functionId, payload?) | always true |
Documents and files
| Function | Returns |
|---|---|
generatePdf(slug, id, templateId, header?, footer?) | Base64 string |
generateWord(slug, id, templateId) | Base64 string |
generateExcel(slug, fields?, filter?) | Base64 string |
generateExcelTemplate(values, templateId) | Base64 string |
GetFileAsync(fileRef) | { bytes, mime, filename, size } or null |
Integration
| Function | Returns |
|---|---|
http(options) | { ok, status, statusText, headers, body } |
promptAgent(agentId, message) | string |
Sequences
These live on context.sequences, not context.functions.
| Function | Returns |
|---|---|
context.sequences.getNext(name) | number |
context.sequences.getCurrent(name) | number |
context.sequences.exists(name) | boolean |
context.sequences.reset(name, value) | true |
Records
Records are flat objects keyed by column name in PascalCase. There is no Attributes wrapper.
{
"ID": 84,
"ClientName": "Acme Corp",
"Amount": 1500.00,
"CreateDate": "2026-03-12T10:24:00.000Z",
"CreateUser": { "ID": 7, "FullName": "John Smith" },
"ModifyDate": "2026-03-12T10:24:00.000Z",
"ModifyUser": { "ID": 7, "FullName": "John Smith" },
"SystemStatusID": 1
}Every entity carries the six system fields ID, CreateDate, CreateUser, ModifyDate, ModifyUser, and SystemStatusID. They are managed by the platform and are stripped from any create or update payload that includes them.
Dates arrive as strings, not Date objects. Lookup fields arrive expanded as objects rather than as bare foreign keys.
Failure is usually silent
Almost nothing throws. create, update, and delete return { success: false }; http returns { ok: false }; the messaging functions return false; getById and GetFileAsync return null. Only promptAgent raises an error on its own.
const result = await context.functions.create("invoices", values);
if (!result.success) throw new Error("Could not create invoice: " + result.message);This is the single most common source of processes that appear to work but quietly do nothing. Error Handling covers it in full.
Coming from the previous backend
Every function below was part of the original Mileva backend and has been removed. There is no shim — a call to any of them throws.
| Previous | Now |
|---|---|
CreateRecord(slug, appId, data, claims) | create(slug, data) — no app id, no claims |
GetRecord(...) | get(slug, options) or getById(slug, id) |
UpdateRecord(...) | update(slug, id, data) |
DeleteRecord(...) | delete(slug, id) |
NotifyAsync(...) | Notify(...) |
NotifyGroupAsync(...) | NotifyGroup(...) |
SendHttpRequestAsync(values), httpGet, httpPost | http(options) |
GetEncodedString(text) | btoa(text) |
CallAIAsync, CallAIWithAttachmentAsync, CallMilevaAsync | promptAgent(agentId, message) |
generatePDF, generatePdfString | generatePdf(slug, id, templateId, header?, footer?) |
GenerateWordFileAsync(slug, id, userId, templateID) | generateWord(slug, id, templateId) |
TemplateToExcelJS, TemplateToExcelJSAsync | generateExcelTemplate(values, templateId) |
executeFrontedFunction(userId, content) | SendFunctionToUserAsync(userId, functionId, payload?) |
throwError(message) | throw new Error(message) |
context.user.id | context.claims.userId |
context.appSlug | context.appDbId |
context.entityName | context.slug |
Removed with no replacement: SendEmailGroup, sendEmailWithAttachments, SendTemplatedEmail, uploadFileFromUrl, GetFile, CreateFolderAsync, CreateMultipleFoldersAsync, clearCacheMeta, manuallyExecuteReadSql, manuallyExecuteNonReadSql, getBankStatements, generateInvoiceXml, validateFiscalizationDocument, and sendFiscalizationDocument.
get() now returns at most 100 records by default — set pagination.take or page through the results. And group filters use { condition, predicates }; the old { operator, filters } keys are ignored rather than rejected, so a legacy filter silently matches everything.