Authoring a wizard
A wizard is one *.wizard.xml file: a <Wizard> root, a flat list of <Node> elements, and a
flat list of <Link> edges connecting them. Every example below is drawn from the canonical sample,
NewProductRequest.wizard.xml.
The XML is a lossless serialisation of the visual designer model — you can hand-author it, paste it into the Wizard Designer, or round-trip between the two.
Root — <Wizard>
Section titled “Root — <Wizard>”<Wizard Name="NewProductRequest" Label="New Product Request" Slug="new-product-request" Schema="Inventory"> ...</Wizard>| Attribute | Required | Meaning |
|---|---|---|
Name |
yes | Unique PascalCase identifier. The immutable lookup key; resolvable in the API by name. |
Label |
yes | Human-readable display title. |
Slug |
no | URL slug for the runner route /form/{slug}. Omitted → derived (kebab-cased) from Name. |
Schema |
no | Database schema context for the wizard’s SQL. |
Nodes — <Node>
Section titled “Nodes — <Node>”Every node shares the same envelope; the Type selects which children and extra attributes apply.
<Node Id="details" Type="Input" Label="Product Details" X="220" Y="-12" Width="200" Height="160"> ...</Node>| Attribute | Meaning |
|---|---|
Id |
Node identifier, unique within the wizard; referenced by <Link>. |
Type |
One of Startup, Input, Decision, Action, Terminal. |
Label |
Display label (step heading in the runner, node caption in the designer). |
X, Y |
Canvas position (designer layout only). |
Width, Height |
Optional canvas size. |
Startup node
Section titled “Startup node”Initialises global variables then auto-advances. Globals are visible to every later step’s SQL and Decision expressions.
<Node Id="start" Type="Startup" Label="Start" X="-60" Y="38" Width="160" Height="60"> <Variables> <Variable Name="Channel" Type="String" Default="Wizard" /> </Variables></Node><Variable> attributes: Name, Type (String | Int | Decimal | Bool | Date |
DateTime), optional Default, and optional FromUrl (default true).
Seeding variables from the URL
Section titled “Seeding variables from the URL”A wizard opened with a query string seeds each declared Startup variable of the same name (case-insensitive). This is how a wizard starts from, or links to, another record:
/form/ReturnRequest?OrderId=42&Reason=Damaged<Variables> <Variable Name="OrderId" Type="Int" /> <Variable Name="Reason" Type="String" Default="Other" /> <Variable Name="Channel" Type="String" Default="Wizard" FromUrl="false" /></Variables>- Precedence: an edit-mode prefill wins, then the URL value, then
Default. - The value is typed by the variable’s
Type. ABoolacceptstrue/1/yes, and a number that doesn’t parse becomes empty (SQLNULL). - Query parameters that match no declared variable are ignored, so the URL cannot inject arbitrary
variables.
FromUrl="false"opts a variable out entirely. idandfloware reserved for edit mode.Session*names are always reserved. The server drops any client-suppliedSession…key, so@SessionUserIdand its siblings are always the live session values.- The URL is user-controlled input. Validate it in your SQL like any other field (for example, check
that
@OrderIdbelongs to@SessionCompanyId).
Prefilling fields with <PrefillSql>
Section titled “Prefilling fields with <PrefillSql>”A Startup node can hold a <PrefillSql>. It runs once, just before the first Input node
renders, so it sees the URL variables and anything that leading Action nodes have set.
Each column of its first row prefills every field whose Name matches the column name
(case-insensitive) on any Input node:
<Node Id="Init" Type="Startup" Label="Initialize"> <Variables> <Variable Name="OrderNumber" Type="String" /> </Variables> <PrefillSql><![CDATA[SELECT c.PreferredCarrier AS Carrier, c.DefaultDock AS DockFROM Sales.Orders o JOIN Sales.Customers c ON c.Id = o.CustomerIdWHERE o.Number = @OrderNumber AND o.CompanyId = @SessionCompanyId AND o.IsDeleted = 0 ]]></PrefillSql></Node>-
A prefill only fills fields that are still empty. It never overrides a value the user typed, and it doesn’t run in edit mode, where the response’s own values are shown.
-
Attachment fields are never prefilled. Null and empty values are skipped, as is a value missing from a field’s static
<Options>. -
Columns that match no field are ignored. The query may return columns dynamically (for example, from a stored procedure that pivots configured values).
-
A failing prefill leaves the fields empty and doesn’t block the wizard. The prefill doesn’t run offline.
-
Key/value shape. When the result has exactly two columns named
FieldNameandValue(case-insensitive), every row is read as one field → value pair instead, and later rows win on a duplicate name. Use it when the field names come from data or configuration: a PostgreSQL function can’t return a dynamic column set, and this works the same on SQL Server.SELECT r.FieldName, r.LastValue AS ValueFROM Ops.RecurringValues rWHERE r.SiteId = @SiteId AND r.CompanyId = @SessionCompanyId AND r.IsDeleted = 0 -
In the default (wide) shape only the first row is used; extra rows are ignored. Values arrive as text and are applied as the field’s value, so return them in the form the field stores (for example
yyyy-MM-ddfor a date, the optionValuefor a select). -
A prefilled value wins over a field’s
Default: defaults are seeded afterwards and only fill fields that are still empty. -
The SQL is substituted like every other wizard SQL block (see SQL substitution):
@Variablefor Startup/URL variables and earlier SetVariable results, plus the@Session…parameters. Scope it to@SessionCompanyIdyourself, as in the example. -
Only the first Startup node’s
<PrefillSql>runs. The designer’s property pane has no row for it yet; author it in the XML view, where completion offers the element. -
At run time the UI calls
POST /api/v1/genie/wizard/{id}/prefill(see Runtime → endpoints).
Input node
Section titled “Input node”Collects user data. Holds a <Fields> block, an optional <Layout>, and an optional
<SubmitSql>.
<Node Id="details" Type="Input" Label="Product Details" X="220" Y="-12" Width="200" Height="160"> <Fields> <Field Name="ProductName" Type="String" Label="Product Name" Required="true" /> <Field Name="CategoryId" Type="Select" Label="Category" Required="true" ControlType="Select2"> <OptionsSql> SELECT Id AS Value, Name AS Label FROM Inventory.Categories WHERE IsDeleted = 0 AND IsActive = 1 ORDER BY Name </OptionsSql> </Field> <Field Name="UnitPrice" Type="Number" Label="Unit Price" Required="true" /> <Field Name="ReorderLevel" Type="Number" Label="Reorder Level" Default="10" /> <Field Name="Justification" Type="Text" Label="Justification" /> </Fields></Node>Fields — <Field>
Section titled “Fields — <Field>”| Attribute | Meaning |
|---|---|
Name |
Variable name. Must be PascalCase and unique across all Input nodes in the wizard. |
Type |
String | Text | Number | Date | DateTime | Boolean | Select | Attachment. Text renders multi-line. |
Label |
Field label. |
Required |
true to require a value before advancing. |
Indexed |
true to store this field as a real, indexable column on the response table — see Storage and indexes. Not available for Text or Attachment. |
Disabled / Readonly |
Render the control disabled / read-only. |
Default |
Seeded value if the field is empty when the step is first shown. |
Mask |
Input mask. |
ControlType |
For Select: Select2 (searchable) or ModalSelector. |
MaxSize, MaxFiles, Accept |
For Attachment: per-file byte cap, file count, accepted MIME/extensions. MaxSize and MaxFiles are enforced when files are chosen: a file over MaxSize is refused with “name is larger than size. Choose a smaller file.”, and choosing more files than MaxFiles allows (counting those already attached, multi-file fields only) is refused with “At most N file(s) can be attached here.” Nothing is uploaded in either case. Set Genie:Uploads:MaxAttachmentBytes to enforce a cap on the server too. |
Field children:
<Options>— static select options:<Option Value="…" Label="…" />.<OptionsSql>— dynamic select options; the query must returnValueandLabelcolumns.<SuggestionsSql>— autocomplete suggestions for aTextfield (@SearchTextis injected).<ExtraMappings>— copy extra columns from the picked dataset row into other variables:<Map Column="Email" Variable="ContactEmail" />(e.g. autofill from a chosen record).
Layout — <Layout> (optional)
Section titled “Layout — <Layout> (optional)”An Input step may arrange its fields with the same layout grammar as views —
<Section> / <Grid> / <Row> / <Column Span> / <Item Name Width> / <Line>. See
Form layout. Layout is pure presentation: it is stored in the XML and
consumed by the React runner; fields not placed in the layout fall through in declaration order.
Decision node
Section titled “Decision node”Branches on the current variables. A Decision has no children — it routes purely through its
outgoing <Link Expression="…"> edges (see Links).
<Node Id="creditCheck" Type="Decision" Label="Over 50k?" X="480" Y="30" />Action node
Section titled “Action node”A side effect that runs during the auto-advance burst. The ActionType attribute selects the flavour:
Alert — pause and show a message the user must acknowledge before the flow resumes:
<Node Id="notify" Type="Action" Label="Heads up" ActionType="Alert"> <Subject>Note</Subject> <Message>This request will need manager approval.</Message></Node>ExecuteSQL — run a SQL statement for its side effect:
<Node Id="touch" Type="Action" Label="Log" ActionType="ExecuteSQL"> <SQL>UPDATE Inventory.Requests SET TouchedAt = SYSDATETIMEOFFSET() WHERE Id = @RequestId;</SQL></Node>SetVariable — compute a variable from a static value or a SQL scalar. Use the SQL form with a
trailing SELECT <scalar> to capture something (e.g. a new row’s SCOPE_IDENTITY()) into a
variable for later steps:
<Node Id="register" Type="Action" Label="Create Draft" X="480" Y="30" ActionType="SetVariable"> <TargetVariable>ProductId</TargetVariable> <ValueSource>SQL</ValueSource> <SQL> INSERT INTO Inventory.Products (Sku, Name, CategoryId, UnitPrice, UnitCost, ReorderLevel, IsActive, Status, IsDeleted, CompanyId, CreatedById, CreatedAt) VALUES (@SkuFormat, @ProductName, @CategoryId, @UnitPrice, @UnitCost, @ReorderLevel, 0, 'Draft', 0, @SessionCompanyId, @SessionUserId, SYSDATETIMEOFFSET()); SELECT CAST(SCOPE_IDENTITY() AS BIGINT); </SQL></Node><ValueSource> is Static (use <StaticValue>) or SQL (use <SQL>, executed as a scalar).
Terminal node
Section titled “Terminal node”Finishes the wizard and, optionally, hands off to a workflow.
<Node Id="done" Type="Terminal" Label="Submitted" X="740" Y="38" Width="160" Height="60" SubmissionStatus="Pending" WorkflowName="ProductApproval" ResubmissionTransition="Resubmitted"> <SuccessMessage>Your product request has been submitted for approval.</SuccessMessage></Node>| Attribute / child | Meaning |
|---|---|
SubmissionStatus |
Status stamped on the saved response (default Submitted). |
WorkflowName |
Workflow definition to start on submit, bound to the response. Omit for no handoff. |
ResubmissionTransition |
Transition label fired when an edited response continues its existing workflow instance (default Resubmitted). |
TransitionEntityType |
Entity type of a linked record whose Active workflow this submission advances. |
TransitionEntityId |
That record’s id: a literal or an @Variable, typically a Startup variable seeded from the URL. |
TransitionLabel |
Transition fired on that record’s Active instance. |
<OnBeforeSubmission> |
SQL run before anything is saved. Reject the submission with THROW/RAISERROR, or by returning a non-empty ErrorMessage (or Error) column; that text is shown to the user and nothing is written. |
<TerminalSql> |
SQL to run at submission time (before the workflow starts). |
<OnAfterSubmission> |
SQL run after the response is saved, <TerminalSql> has run and the workflow has started, with @WizardResponseId and @WorkflowInstanceId (null when no workflow). A failure is logged and reported, but does not undo the submission. |
<SuccessMessage> |
Message shown on the completion screen. |
Before and after submission
Section titled “Before and after submission”Each Terminal can carry two hooks around the save. They run for the Terminal the user actually reached (with several Terminals, each has its own), and are string-substituted with the collected values like the other wizard SQL:
<Node Id="done" Type="Terminal" Label="Submitted" WorkflowName="ProductApproval"> <OnBeforeSubmission><![CDATA[ IF EXISTS (SELECT 1 FROM Catalog.Products WHERE Sku = '@Sku' AND IsDeleted = 0) SELECT 'A product with this SKU already exists.' AS ErrorMessage; ]]></OnBeforeSubmission> <OnAfterSubmission><![CDATA[ UPDATE Catalog.ProductRequests SET ResponseId = @WizardResponseId WHERE Id = @RequestId; ]]></OnAfterSubmission></Node>Order on submit: OnBeforeSubmission → save the response → TerminalSql → workflow →
OnAfterSubmission. Both hooks are SQL, so they are stripped from portable
.gwiz documents and run only on the server.
Advancing a linked record’s workflow
Section titled “Advancing a linked record’s workflow”When the wizard was opened from a record that is already in a workflow, the Terminal node can move that workflow on as part of the submission:
<!-- opened as /form/ReturnRequest?OrderId=42 --><Node Id="done" Type="Terminal" Label="Return logged" TransitionEntityType="Order" TransitionEntityId="@OrderId" TransitionLabel="ReturnRequested" WorkflowName="ReturnApproval" />- The three attributes are read from the stored definition of the Terminal node the run reached, never from the request. All three are required together.
- The record’s Active instance is looked up before the response is saved. If there is none, or the id doesn’t resolve, the submission fails and nothing is written.
- The transition runs as the submitting user, with the wizard’s values plus
WizardResponseIdas workflow context. The transition’s own guards and roles still apply. If the transition itself fails, the response is already saved and the error says so. - It is independent of
WorkflowName: one Terminal can advance the linked record’s flow and start a new workflow on the response. - In resubmit mode (
?flow=),ResubmissionTransitiongoverns and the linked transition is skipped.
For anything conditional or multi-record, use workflow callbacks from <TerminalSql> instead (next
section).
Workflow callbacks from <TerminalSql>
Section titled “Workflow callbacks from <TerminalSql>”<TerminalSql> runs through the same dispatch pipeline as a form’s SQL. When its final result set is a
callback row, the workflow callbacks (startWorkflow, transitionWorkflow,
transitionEntityWorkflow and workflowSubmitApproval) execute on the server, with the wizard’s
variables as context:
<TerminalSql> UPDATE Orders SET ReturnReason = @Reason WHERE Id = @OrderId; SELECT 'transitionEntityWorkflow' FunctionName, 'Order', @OrderId, 'ReturnRequested';</TerminalSql>Wizards run only these server callbacks. UI callbacks such as toasts or navigation are ignored, with a warning in the log.
Links — <Link>
Section titled “Links — <Link>”Directed edges between nodes. The runner follows them from the start node onward.
<Link From="start" To="details" /><Link From="details" To="register" /><Link From="register" To="done" />| Attribute | Meaning |
|---|---|
From, To |
Source and target node Id. |
Expression |
On a Decision node, the branch condition. First true link wins; Expression="else" (or an expression-less link) is the catch-all. |
FromSide, ToSide |
Which node port the edge attaches to (designer routing only). |
SQL substitution
Section titled “SQL substitution”SQL blocks (<PrefillSql>, <OptionsSql>, <SuggestionsSql>, SetVariable/ExecuteSQL <SQL>,
<SubmitSql>, <TerminalSql>) are string-substituted before execution — this is not a parameterised command:
@FieldNameand@NodeId__FieldNameare replaced with the collected value; strings are auto-quoted, booleans become1/0, andNULLis emitted for empty values.- Session parameters are injected:
@SessionUserId,@SessionCompanyId,@SessionCartId. - Dataset/options queries also receive
@SearchTextfor optional filtering. - Any declared field or Startup variable the user didn’t supply is substituted as SQL
NULL, so referencing an optional blank field never raises “Must declare the scalar variable @X”. - T-SQL locals you
DECLAREinside the SQL body are not wizard variables and are left untouched.
Storage and indexes
Section titled “Storage and indexes”Each wizard’s submissions go into its own table, Wizard.Resp{Name}. Every response keeps its full
set of values as JSON, and any field you mark Indexed additionally gets a real column that can be
filtered, sorted and searched.
<Field Name="SKU" Type="String" Label="SKU" Indexed="true" />Marking a field Indexed does three things: it becomes an indexable column, it becomes searchable, and
it appears in the generated response grid. Fields you leave alone stay in the JSON
payload — still submitted, still readable, just not queryable. Text and Attachment fields cannot be
indexed at all, because their values are unbounded in length.
<Indexes>
Section titled “<Indexes>”Declare database indexes in an <Indexes> block at the <Wizard> root, using the same grammar as
entity indexes:
<Wizard Name="NewProductRequest" Label="New Product Request"> <Indexes> <!-- Enforce one product request per SKU --> <Index Name="Sku" Unique="true"> <FieldRef Name="SKU" /> </Index>
<!-- Composite index for a category-filtered, newest-first grid --> <Index Name="CategoryRecent"> <FieldRef Name="CategoryId" /> <FieldRef Name="CreatedAt" Sort="Desc" /> </Index>
<!-- Partial index: only the approved rows --> <Index Name="ApprovedSku" Filter="Status = 'Approved'"> <FieldRef Name="SKU" /> </Index> </Indexes>
<Node Id="details" Type="Input" ...>| Attribute | Meaning |
|---|---|
Name |
Author-facing name. The physical name is prefixed with the table (IX_Resp{Name}_{Name}), because PostgreSQL scopes index names to the schema rather than the table. |
Unique |
true to enforce uniqueness. |
Filter |
Optional predicate for a partial index. Must be a single boolean expression. |
<FieldRef Name Sort> |
One key column, in order. Sort="Desc" for descending. |
A <FieldRef> may name a wizard field or a built-in response column — Id, Status,
ReferenceId, CreatedAt, CreatedById, UpdatedAt, CompanyId, IsDeleted, UpdatedTo,
VersionHash, SchemaHash. Referencing a built-in is what makes a company-scoped, recency-ordered
index possible. A field referenced by an index is treated as Indexed whether or not you set the
attribute — you cannot index a column that was never created.
Indexes are declared at the root because a wizard can have several Terminal nodes but has exactly one response table; per-Terminal declarations could disagree with no principled way to merge them. The designer surfaces the editor in the Terminal pane, under Storage & Indexes, since that is where the whole flow’s fields are already in view — but every Terminal edits the same root-level list.
Genie also creates a few indexes on every response table regardless: latest-in-lineage lookups, status filtering, and company-scoped recency ordering.
The response grid
Section titled “The response grid”Once provisioned, a wizard’s submissions are browsable at /table/Resp{Name} — a normal Genie table
view, generated for you, with the full RBAC and row-security stack. It shows the indexed fields plus the
response metadata. The object is registered as a permission resource automatically, but no role is
granted it: grant Resp{Name} to the roles that should see the submissions.
See Runtime & designer for how the table is provisioned, and how
SchemaHash keeps a cosmetic edit from triggering DDL.
Copyright © 2026 Orbyn Technologies. All rights reserved.