Skip to content
Verified

Alert

A reusable message, title, body, severity and display surface, called by id from anywhere in the project.

An Alert is a reusable notification: a title, a body, a severity and where it surfaces, defined once and raised the same way from any Component, workflow or JavaScript program with call_alert. It keeps a message like "profile saved" or "file not found" consistent everywhere it is shown instead of retyped at every call site.

Properties

alertData

progFields

Optional parameters a caller substitutes into the title or body, the standard virtual field shape, referenced inside alertTitle / alertBody as @field_id.

Calling an Alert

json
{
  "id": "1", "data": {
    "action": "call_alert",
    "name": { "prog": "5b1_alr_…", "properties": {}, "parameters": { "file_name": { "fx": "@document_name" } } },
    "enabled": true
  }, "props": {}
}

An inline alert skips the reusable program entirely, the alert action carries alertTitle, alertBody, alertType, alertDisplay and createLog directly on the workflow step.

Avoid xu.alert in Studio previews

A modal, toast or browser display can surface as a native blocking browser alert() inside a live-preview session, freezing all JavaScript until it is dismissed. Report status through a field instead while testing in preview, and confirm the real display surface in a deployed app.

Worked example

Write the message once

Title, body, severity and surface, on alertData.

Parameterize it

Add a virtual field for anything the caller should fill in, reference it as @field_id inside the body.

Raise it from anywhere

call_alert with this program's id, from a Component's xu-on:click, from a set_data program's after_record, from a Batch step.

Create an Alert node under Programs, fill in title, body, type and display on its Alert tab, add parameters on the Fields grid if the message needs them.

xml
<meta lang="json5">
{
  id: "student_saved",
  menuTitle: "Student Profile Saved"
}
</meta>

<alert lang="json5">
{
  alertDisplay: "toast",
  alertType: "success",
  alertTitle: "Profile saved",
  alertBody: "The student profile was saved through the DBS-backed student table.",
  createLog: false
}
</alert>
json
{
  "properties": { "menuType": "alert", "menuName": "File Not Found" },
  "alertData": {
    "alertType": "error", "alertDisplay": "modal",
    "alertTitle": "File not found", "alertBody": "The file \"@file_name\" could not be located."
  },
  "progFields": [
    { "id": "b2c3d4e5-…", "data": { "field_id": "file_name", "type": "virtual" }, "props": { "fieldType": "string" } }
  ]
}