Portal Community

widget API

The widget object provides read access to the current widget's data and configuration:

Property / MethodTypeDescription
widget.widgetIdstringThe widget's unique ID
widget.typestringThe widget type (e.g., "DataGrid", "Chart", "Form")
widget.dataobjectThe widget's current loaded data (rows, total, metadata)
widget.propsobjectThe widget's resolved configuration (column definitions, chart config, etc.)
widget.selectedRowobject | nullThe currently selected row (for grids and lists)
widget.formValuesobjectCurrent 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:

MethodDescription
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:

MethodDescription
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:

PropertyTypeDescription
context.userIdstringAuthenticated user ID
context.tenantIdstringCurrent tenant ID
context.rolesstring[]User's role names
context.displayNamestringUser's display name
context.emailstringUser's email address
context.claimsobjectAll 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