Skip to content
iQBus HomeDocumentationBlogContact
Updated November 14, 2026
Core concepts/Variables

Variables

Application-scoped, dynamically-typed slots written by ports and pipeline components and readable from anywhere in the application. The value travels with its message by default; switch a variable to Global and one value is shared by every message debatched from the same arrival.

A variable in iQBus is a named value defined under an Application, alongside schemas and message types. The name belongs to the application, and any port, pipeline component, map, or routing expression in that application can read it. The value travels with the message by default; switch the variable’s Global toggle on and it holds one value per Tracking ID instead, shared by every message debatched from the same arrival. Writing is restricted to two places: a port’s Open Variables / Close Variables assignment stages and a pipeline component returning a Variables dictionary on its output. Maps, custom functions, and other expression contexts are read-only with respect to variables.

Variables carry whatever the integration needs to remember between stages: a counter for a looping pipeline, a fragment captured out of the inbound payload by an XPath, a whole message held for later wrapping, a correlation key. Values that are fixed per environment, an endpoint URL, a partner identifier, belong in Constants; a variable is for state that changes while the integration runs. Anywhere a string can be typed in the platform, a variable can be referenced with {{Variable.Name}}.

A variable is declared once at the application level, and what every port and pipeline in that application shares is the declaration: the name. Where the value lives depends on the variable’s Global toggle.

Global off, the default: the value travels with the message. A receive port writing CurrentBatchId and a send port reading {{Variable.CurrentBatchId}} later in the same flow see the same value, because the send port is handling the message that carries it. When a pipeline component splits one interchange into two hundred messages, each of the two hundred inherits a copy of the values its parent held at the split, so a batch id written before the split is readable on every record. From then on the copies are independent: a write on one record changes that record’s copy and no other.

Global on: one value per Tracking ID. The variable holds a single value for the arrival, the unit that carries one Tracking ID through every hop. All two hundred debatched records read and write that one value, so a write from one record is visible to the records that read it afterwards.

Neither kind crosses arrivals. A message received separately gets its own Tracking ID, so its ordinary and Global variables start empty and stay invisible to every other arrival.

ONE ARRIVAL, ONE TRACKING ID copies inherit at the split, then diverge; a Global value is shared ARRIVAL Interchange, 3 records BatchId = "B-77" written before the split DEBATCH RECORD 1 own copy BatchId = "B-77" inherited LineStatus = "OK" own write RECORD 2 own copy BatchId = "B-77" inherited LineStatus = "Rejected" own write RECORD 3 own copy BatchId = "B-77" inherited LineStatus = "OK" own write GLOBAL VARIABLE AnyLineRejected "true" one value per Tracking ID writes reads reads A message received separately gets its own Tracking ID and shares neither kind.
Practical effect. Use a promotion when the value is intrinsic to a single message, a CustomerId on this Invoice, a Currency on that Order. Use a variable when the value is a piece of state the integration carries forward, a loop counter, a captured fragment for later use, or a correlation key, and switch it to Global only when the records split from one arrival must see each other’s writes. A value that never changes at runtime belongs in a Constant.

Variables are scoped to an Application. From the application menu, the Variables list shows every variable defined in that application. Each entry has these fields:

FieldPurpose
NameRequired. How the variable is referenced everywhere else, in port assignments, pipeline component property values, map bindings, custom function arguments, and routing expressions. Names are flat under the Variable namespace, so they must be unique within the application.
ApplicationRequired. The Application that owns the variable. Preselected when an Application is selected, see below.
GlobalA toggle, off by default. Off: the value travels with the message, and each message produced by a debatch inherits its own copy. On: one value per Tracking ID, read and written by every message debatched from the same arrival. The token is {{Variable.Name}} either way. See Per message by default, per Tracking ID when Global.
DescriptionFree-text description for human readers. Optional, has no runtime effect.

The list view follows the platform's Selected Application behavior, with an Application selected, the list filters to it and the Application column is hidden; with no selection, the list spans every Application you have access to and the column is shown. Creating a new variable uses the same flow: with an Application selected, the form opens with that Application preemptively chosen; without one, the form exposes an Application picker.

No data type field. Variables are deliberately untyped at declaration time, the slot is allocated, but its shape is decided by what gets written into it. See Dynamic typing below.

A variable does not declare a data type at design time. The runtime type is whatever the most recent assignment produced, the same slot can hold a string in one stage, a node-set in another, and a whole XML document in a third.

This mirrors the way promotions resolve: a variable can hold any of the same four shapes an XPath promotion can return, and the source of the assignment determines which one.

SCALAR Single value "true" Literal, scalar XPath, or function return Variable. FeatureFlag LIST Repeating values SKU-001 SKU-002 SKU-003 SKU-004 XPath node-set Variable. CapturedSKUs SUB-TREE Inner element <ShipTo> Name Street City Element + children Variable. ShipToFragment WHOLE MESSAGE Document root <Order> Header Lines ShipTo </Order> XPath of / Variable. OriginalRequest
Source of the assigned valueVariable holds
A literal string in the port's variable assignment UIScalar string
An XPath that resolves to a single text node or attributeScalar string
An XPath returning multiple matchesList (node-set)
An XPath returning an element with childrenSub-tree
An XPath of /The whole message
A custom function callWhatever the function returns
A pipeline component returning the value in its Variables dictionaryWhatever the component writes

Downstream consumers see the value as it currently is. A map that reads {{Variable.CapturedHeader}} will receive a sub-tree if that is what was last written; passing the same token to a string-only context (a header name, a literal in a subscription expression) coerces to text.


Anywhere a string can be typed in the platform, subscription expressions, map bindings, pipeline component property values, custom function arguments, port adapter settings, you can reference a variable with a double-curly-brace token. The exception is naming an object itself: the Name field on a variable, port, message type, schema, etc. is a literal, never an expression.

TokenResolves to
{{Variable.Name}}The current value of the named variable: the message’s own copy, or the value shared across the arrival when the variable is Global. Resolves to a scalar, list, sub-tree, or whole message depending on what was last written into the slot.

The token grammar is identical to {{Promoted.MessageType.Name}} and {{Message.MessageType}}, the same expression engine evaluates all three. A subscription expression that filters a send port to only pick up messages while a feature flag is on, for example, looks like this:

EXPRESSION
{{Message.MessageType}} == "Invoice" && {{Variable.InvoiceForwardingEnabled}} == "true"

A pipeline component can also write to a variable, by returning an entry in the Variables dictionary on its PipelineComponentOutput, which is the canonical way to surface a derived value out of a pipeline for the rest of the flow to consume. See Pipeline components.


Declaring a variable allocates the slot. Giving it a value is the job of port variable assignments, an optional stage that runs immediately after the port has been entered and immediately before it is left. Every port type exposes the same two assignment points, regardless of how much else the port carries:

PORT TYPE STAGES: Variables appear in every row Receive one-way request side STAGE 1 Adapter STAGE 2 Open Vars STAGE 3 Pipeline STAGE 4 Map STAGE 5 Close Vars → Bus Send one-way request side Bus → STAGE 1 Open Vars STAGE 2 Map STAGE 3 Pipeline STAGE 4 Close Vars STAGE 5 Adapter Loopback outbound side shown Bus → STAGE 1 Open Vars STAGE 2 Map STAGE 3 Pipeline STAGE 4 Close Vars ↻ Turnaround Null discard sink Bus → STAGE 1 Open Vars STAGE 2 Map STAGE 3 Pipeline STAGE 4 Close Vars Discarded

The two stages always sit at the edges of the port: Open Variables runs immediately after the port is entered, before pipelines or maps; Close Variables runs immediately before the port is left, after any pipelines and maps. A two-way port runs both stages on the request and again on the response, mirrored. The numbered stage diagrams in the Receive, Send, Loopback, and Null port articles show the full numbering for each direction.

Every port type has both assignment points. Loopback and null ports have no adapter, but they still run the full set of optional map and pipeline stages, a loopback on both sides of its turnaround, a null port before the discard, and Open Variables / Close Variables bracket those stages on every port type, useful even when no other transformation is configured.
Open Variables runs before the pipeline, but not before the message has a type. On a receive port the runtime stamps the port’s required Adapter Message Type the instant the adapter hands the message to the next step inside the port, which is ahead of Open Variables, and it evaluates that type’s promotions against the arriving payload at the same moment. So at Open Variables both tokens resolve: {{Message.MessageType}} gives the Adapter Message Type, and {{Promoted.MessageType.Name}} gives a promotion defined on that type. What is not available is anything a pipeline component or a map sets later, so a promotion belonging to a type stamped further downstream has nothing behind it at this stage. The same applies to the response section of a two-way send port, the other position where a message enters the bus. Close Variables runs after the map, so by that stage the message carries its post-map type and that type’s promotions. See When a message type is instantiated.

The port assignment stages are not the only writers. A pipeline component can also write variables by returning entries in the Variables dictionary on its PipelineComponentOutput, see Variables & Message Type in the component reference. The slot updated by a pipeline component write is the same slot the port assignment stages write to; downstream stages cannot tell which path produced the value.


Four patterns account for most of how variables are used in practice; the first three are pictured below, and the fourth needs Global. The platform does not enforce any of these, a variable is just a slot, but the patterns are worth recognizing because they show up across most non-trivial integrations.

PATTERN 1 Loop counter i = 0 i = 1 i = 2 read, use, increment, write back {{Variable.RecordIndex}} travels with the message PATTERN 2 XPath capture <Order> Header CorrelationId Lines "X-2026-42" /Order/Header/ CorrelationId/text() PATTERN 3 Held fragment <Order> Header Lines </Order> VARIABLE OriginalRequest drop into a later envelope /, the whole message

Pattern 1, Loop counter. A countdown loop works through a batch on the bus one element per pass: a send port processes the element at the current index, its Close Variables stage writes the new count back, and the message re-publishes itself for the next pass. The count lives in a variable:

EXPRESSION
{{Variable.RecordIndex}}

Each pass reads the current value, uses it, and writes the next one back. Because an ordinary variable travels with the message, the count goes round the loop with it, no need to thread it through component arguments, and two batches looping at the same time each keep their own count.

Pattern 2, Body capture. A common need is to lift a value out of the inbound message and reference it later in the flow, without making it part of the message type as a promotion. An Open Variables assignment whose expression reads from the body does exactly that:

VariableExpression
CorrelationId{{Message.Body}}.XPath("/Order/Header/CorrelationId")

From that point on, every later stage that handles this message, and every record debatched from it, can reach {{Variable.CorrelationId}}, a send port can use it in a subscription expression, a map can drop it into the response, a pipeline component can log it. The value is a scalar string, because that is what the body path returned.

Pattern 3, Holding a fragment or a whole message. The same body-path read works for sub-trees and whole messages. To capture an entire envelope inbound for later wrapping:

VariableExpression
OriginalRequest{{Message.Body}}.XPath("/")

The variable now holds the whole message as a sub-tree. A two-way send port further along can drop {{Variable.OriginalRequest}} into an outbound envelope produced by a map, embedding the original payload verbatim. The same technique with a more selective path, {{Message.Body}}.XPath("/Order/ShipTo"), say, captures just that branch.

Pattern 4, A flag any record can raise. This one needs Global on. An interchange of order lines is debatched, and one rejected line should mark the whole batch for review. Declare AnyLineRejected with Global on, and give the send port that handles rejected lines a Close Variables assignment:

VariableExpression
AnyLineRejectedtrue

Every record of that arrival that reads {{Variable.AnyLineRejected}} after the write gets "true", whichever record raised it. With Global off, the write would change only the rejected record’s own copy, and its siblings would never see it.

Build Global logic on writes whose order does not matter. A record that already read the variable does not see a later write from a sibling. A flag that any record can raise gives the same result in any order. A running total that each record reads, increments and writes back depends on the order of the records and on no two of them writing at once.

Variables are evaluated lazily. The runtime does not pre-resolve every variable reference at the start of a flow; it resolves each {{Variable.Name}} token at the moment the stage that contains it executes.

StageWhat happens
Slot allocationWhen a message arrives, every variable defined on the application gets a fresh slot for that arrival: one per message for an ordinary variable, one per Tracking ID for a Global one. Until something writes to it, reading it returns an empty value.
AssignmentA port Open Variables / Close Variables stage or a pipeline component writes a value. An ordinary variable changes on the message being processed; a Global variable changes for every message of the arrival. The slot's runtime type becomes whatever was just written.
DebatchEach message produced by the split inherits a copy of every ordinary variable as its parent held it. Global variables are not copied: the records keep sharing the one value held for the Tracking ID.
Reference resolutionAn expression containing {{Variable.Name}} is evaluated, the slot's current value is substituted in, with shape coercion if the consuming context demands a string.

The name is defined application-wide, but values never cross arrivals: two messages that arrived separately and are flowing through the same application at the same time each have their own values, Global or not, and one’s assignment never affects the other’s. Within one arrival, ordinary variables split along with the message and Global ones stay shared, so the two hundred records a debatching component emits all start from what was written before the split, and only a Global variable carries a write from one record to the others.



That is the whole job

Define a slot under the application, fill it from a port stage or a pipeline component, reference it as {{Variable.Name}} wherever you need it. Untyped and defined on the application; the value travels with the message, or with the whole arrival when Global is on.