Skip to content

Callback functions

A SQL block can tell the app what to do next instead of just returning a value. Return a result set whose first column is named FunctionName; each row is one callback, and the other columns are its parameters in column order.

SELECT 'showAlert' FunctionName, 'success', 'Created',
'Plan created. Use Generate, upload rows or add lines manually.';

This works from any write-side <Sql>: a form’s insert/update, a delete, a row or toolbar action, an import AfterSql, and RPC blocks.

  • Name. The first column must be called FunctionName (any case). Its value must match ^[A-Za-z_][A-Za-z0-9_]*$.
  • Parameters are positional. The 2nd column is Param1, the 3rd Param2, and so on. Column names after the first don’t matter. SQL NULL arrives as null.
  • Rows run in order, one at a time. Each callback finishes (e.g. the user closes the dialog) before the next row runs. Chain several with UNION ALL or by selecting more than one row.
  • Every row in a UNION ALL needs the same column count. Pad shorter callbacks with NULL.
  • An unknown name stops the chain and shows an Unknown action dialog, so a typo is visible.
Kind Runs in Names
UI callbacks the browser, through a closed registry (no eval, no inline JS) refreshTable, showAlert, showSuccess, showError, swal, closeModal, navigate, historyBack, openWindow
Server callbacks the engine, inside the same request startWorkflow, transitionWorkflow, transitionEntityWorkflow, workflowSubmitApproval

The engine runs server callbacks itself and removes them from the response, so the browser never sees them and there is no public endpoint for them. One result set can mix both kinds:

SELECT 'startWorkflow' FunctionName, 'OrderApproval', 'Orders', @Id -- runs on the server
UNION ALL
SELECT 'showSuccess', 'Submitted', 'Sent for approval.', NULL; -- runs in the browser
FunctionName Params Effect
refreshTable — Reload the surrounding grid or record.
showAlert severity, title, message Dialog. Severity: success, error, info, warning or question (anything else shows as info).
showSuccess title, message Success dialog.
showError title, message Error dialog.
swal title, message, severity Legacy alias for showAlert, with the old parameter order. Severity defaults to error.
closeModal — Close the surrounding modal.
navigate url Go to a URL. Internal paths (/object/orders?id=5) navigate in the app; absolute URLs do a full page load. javascript: URLs are refused.
historyBack — Browser back.
openWindow url, target, features window.open. Target defaults to _blank, features to noopener,noreferrer. javascript: URLs are refused.
-- Validation message that keeps the form open so the user can fix it:
IF @EndDate < @StartDate
BEGIN
SELECT 'showAlert' FunctionName, 'error', 'Invalid dates', 'End date must be after the start date.';
RETURN;
END
-- Save, confirm, and go to the new record:
INSERT INTO [Planning].[Plans] (Name) VALUES (@Name);
DECLARE @NewId BIGINT = CAST(SCOPE_IDENTITY() AS BIGINT);
SELECT 'showSuccess' FunctionName, 'Created', 'Plan created.', NULL
UNION ALL
SELECT 'navigate', CONCAT('/object/plans?id=', @NewId), NULL, NULL;
-- Row action that only needs the grid reloaded:
UPDATE [Sales].[Orders] SET Status = 'Approved' WHERE Id = @Id;
SELECT 'refreshTable' FunctionName;
-- Open a generated document in a new tab:
SELECT 'openWindow' FunctionName, CONCAT('/api/v1/report/invoice?id=', @Id), '_blank', NULL;

After the callbacks run, a form or row action decides whether to do its default follow-up: a form returns to where it came from or closes its modal, and a row action reloads the grid. It does this only when every row was a harmless follow-up:

  • refreshTable, closeModal or showSuccess, or
  • showAlert / swal with severity success.

Any other row keeps the screen where it is. That includes an error or warning alert, a navigate, or an openWindow. So an error alert leaves the form open for correction, and navigate decides where the user goes. You don’t need to add refreshTable after a success message; the grid reloads once either way.

These start or move a workflow from the same SQL that saved the record. Signatures, in brief:

FunctionName Params
startWorkflow WorkflowName, EntityType, EntityId [, …context columns]
transitionWorkflow InstanceId, TransitionLabel [, Comment] [, …context columns]
transitionEntityWorkflow EntityType, EntityId, TransitionLabel [, Comment] [, …context columns]
workflowSubmitApproval InstanceId, NodeKey, Decision, Comment
UPDATE [Inventory].[PurchaseOrders] SET Status = @Status WHERE Id = @Id;
SELECT 'transitionEntityWorkflow' FunctionName, 'PurchaseOrders', @Id, 'Resubmitted', @Comment;

Full rules, context columns and batch starts are in Workflow callbacks.

The UI registry is closed: a host app cannot register a new FunctionName. This is deliberate. A callback name comes from SQL data, so an open registry would let any value in a result set call host code. To change how the app looks or behaves from a project, use the host extension points instead: Custom UI functions covers expression functions, cell renderers and cell classes.