Using Dynamic Variables
Dynamic Variables provide a powerful way to manage and change data that is used in a Flow during runtime, including data that is brought to the X‑Platform from external sources like databases and Natural Language Processing (NLP) engines.
A Dynamic Variable always consists of a JSON object, enabling its content to be changed anytime to suit the current data needs of a Flow.
Dynamic Variables are created and maintained like any Session Variable in Interact, and you can use them in most X-Designer elements like any other variable.
Creating a Dynamic Variable
![]() |
Note
While Dynamic Variables are very flexible, they cannot be used as a field when defining a Custom Type in the X-Console. However, you can use a Dynamic Variable to assign the value of a Custom Type field during runtime (for example, when using an Allocator).
Accessing a Dynamic Variable with JSON
Because a Dynamic Variable is not a strictly defined type on X‑Platform, you can add content to it directly using standard JSON code. You can see an example of doing this with the Allocator below.
To access specific values from a Dynamic Variable, you use an object-style format:
[dynamic-variable-name].[element-name]
For example: RentalPackage.checkin
Using a Dynamic Variable in the Allocator
Dynamic Variables are especially useful when allocating values to variable using the Allocator.
Because you can assign and change its content using a standard JSON object, a Dynamic Variable enables great flexibility in how your Flow can proceed. You can add or remove JSON elements to the Dynamic Variable at any time, as well as change the entire structure of the Variable, if needed. You can also use JSON objects that are supplied from external sources like databases and NLP engines.
In the example shown below, (A) shows how we can assign information to a Dynamic Variable named RentalPackage
by entering or pasting valid JSON code. The complete object looks like this:
{ "pkg-id":"GB3721-114", "city":"London", "agent":"Morris", "location":"Regency Arms", "rooms":1, "adults":2, "extras1":"king size bed", "extras2":"park view", "extras3":"breakfast", "days":5 }
This code may also be supplied by entering another Dynamic Variable instead of the code itself. In (B) we enter a static date to assign the value of the Dynamic Variable element named RentalPackage.checkin
. In (C) we use regular variables for an allocation.
![]() |
We can design a paragraph element with Dynamic Variables that use the values we have allocated:
![]() |
During runtime, we can see how the resulting Dynamic Variables are parsed from the JSON:
![]() |
We've also added the full JSON object at the end of the example to show the complete content of the Dynamic Variable following the assignment in the Allocator.
Using a Dynamic Variable in Other X-Designer Elements
A Dynamic Variable can be used like any other variable in:
Allocators
Global Rules
Decision Points
Integration Points
Show/Hide Rules
Choices
Navigation Buttons
Page Names
Paragraphs
Response Elements
Sub-Flows
Hyperlinks
Emails
When added to a X-Designer element, a Dynamic Variable uses an object-style format:
[dynamic-variable-name].[element-name]
Here's an example of how a Dynamic Variable can appear in a Decision Point:
![]() |
Just like any other variable, X-Designer will notify you of data conflicts that arise when using the Dynamic Variable in a Flow. Similarly, X-Designer will not allow you to rename or delete any Dynamic Variable that is currently used by an Approved Flow.
Defining a Default Value for a Dynamic Variable
When needed, you can define the default JSON object for a User or Session Dynamic Variable.
When creating a new User Dynamic Variable from the Solution Explorer or with the autocomplete function, the Variable Editor opens with a built-in JSON editor in the Default Value section:
To edit an existing Dynamic Variable, use the Solution Explorer to locate the Dynamic Variable you want to add the default value to, then click the Edit
icon at the right.
Enter or paste your JSON object into the JSON window in the popup. You can use the various tools located at the top of the JSON window to quickly format, validate and add more structures to your object:
By default, the editor opens showing formatted JSON in Code view mode. Clicking on the Compact button will display your code with all spaces and line breaks removed.
If the JSON object contains a syntax error, you'll see an Error
icon on the line containing the error. Hovering over the icon will display a repair hint for that line:
Note
You cannot save the Dynamic Variable until all syntax errors are corrected.
While working in Code view mode, clicking the Repair button
provides some simple code repair functions.
You can change the view mode to display the JSON as a object tree. When working in Tree view mode, the editor creates the object structure for you, preventing syntax errors. You can select an object and click on its
icon (at the left side of the tree) to access additional editing and coding functions. You can also perform searches for specific objects.
The editor uses the JSON Editor Online web-based tool. For complete details about its functionality, click here.
When finished preparing the default JSON object, click Save Variable. The new Dynamic Variable is stored and the Variable Editor closes.