App Studio
Available APIs
The Custom JS sandbox exposes four API objects as function parameters: widget (current widget state), variables (read/write app variables), actions (trigger app-level actions), and context (current user identity). Nothing else is accessible.
widget API
The widget object provides read access to the current widget's data and configuration:
| Property / Method | Type | Description |
|---|---|---|
widget.widgetId | string | The widget's unique ID |
widget.type | string | The widget type (e.g., "DataGrid", "Chart", "Form") |
widget.data | object | The widget's current loaded data (rows, total, metadata) |
widget.props | object | The widget's resolved configuration (column definitions, chart config, etc.) |
widget.selectedRow | object | null | The currently selected row (for grids and lists) |
widget.formValues | object | Current form field values (for Form widgets) |
variables API
Read and write app-level variables. Writing a variable triggers a re-render of all widgets that bind to it:
| Method | Description |
|---|---|
variables.get(name) | Read the current value of an app variable |
variables.set(name, value) | Write a value to an app variable; triggers reactive re-render |
variables.getAll() | Returns all app variables as a plain object (read-only snapshot) |
// Reading and writing variables
const currentFilter = variables.get('statusFilter'); // e.g., "active"
// Compute and set a new variable
const total = widget.data.rows.reduce((sum, r) => sum + r.amount, 0);
variables.set('grandTotal', total);
actions API
Trigger App Studio actions from code. All action calls are async — they return a Promise but the sandbox does not support top-level await. Use .then() for chaining:
| Method | Description |
|---|---|
actions.navigate(path, options?) | Navigate to a route path. Options: { mode: 'push' | 'replace' | 'new-tab' } |
actions.openModal(modalId, params?) | Open a modal widget by ID, optionally passing params as modal variables |
actions.closeModal() | Close the currently open modal |
actions.triggerWorkflow(workflowId, inputs) | Fire a workflow and return a Promise resolving to the output |
actions.showNotification(message, variant?) | Show a toast notification. Variants: "info", "success", "warning", "error" |
context API
Read-only access to the current user's identity from the Passport JWT:
| Property | Type | Description |
|---|---|---|
context.userId | string | Authenticated user ID |
context.tenantId | string | Current tenant ID |
context.roles | string[] | User's role names |
context.displayName | string | User's display name |
context.email | string | User's email address |
context.claims | object | All custom JWT claims |
Standard JavaScript Available
Within the sandbox, standard JavaScript is fully available:
// Available standard JS:
Array.prototype.* (map, filter, reduce, sort, find, etc.)
Object.keys(), Object.values(), Object.entries()
Math.*
Date (read-only — no system clock manipulation)
JSON.parse(), JSON.stringify()
String.prototype.*
Number, Boolean, parseInt, parseFloat
console.log() (output to the editor's test panel)
try/catch/finally