Variables, parameters, and dynamic values
Variables let an interface display and react to changing values. Use a global variable for a project-wide value such as volume or lighting feedback. Use a page parameter to configure a reusable page independently for each instance.
This guide covers AVstudio Editor NG 27.0.29. The examples use local variables and page parameters; configure and test equipment feedback separately when connecting a control processor.
Choose the right scope
| Value source | Where it is defined | Reference | Typical use |
|---|---|---|---|
| Global variable | global.variables at the project root | $volume$ | A level or status shared across the project |
| Page parameter | parameters inside a .page file | %roomName% | A label or identifier supplied to one page instance |
| Attached datasource | The element's Attached datasource setting | #datasources/rooms.datasource:0.name# | A field from the attached data result |
| Current list record | A Subpage List's attached array and input mapping | #datasources/rooms.datasource:*.name# | A different room name for each repeated card |
A global variable and a page parameter may have the same name, but they are different values. Choose the scope based on where the value is actually defined. Creating roomName in a page does not create a global $roomName$.
Create a global variable in VS Code
- Open your AVstudio project workspace.
- Open the Command Palette and run AVstudio: Open variables. NG opens Global Variables using the AVS Forms Editor.
- Click Create new variable.
- Enter a unique Name, such as
volume. - Select number and set Default value to
25. - Click Create variable, then save the file.
The dialog changes its default-value control to match the selected type:
| Type | Value to enter | Example |
|---|---|---|
| string | Text | Conference Room |
| number | A numeric value | 25 |
| boolean | TRUE or FALSE | false |
Use letters, digits, and underscores, up to 64 characters. Avoid spaces and punctuation. Names must be unique within the global-variable map, or within the current page's parameter map. Match the spelling and case in every reference.
Understand the Global Variables table
The sample contains username (string), docsLightOn (boolean), and the new volume (number). docsLightOn is the value used by the Modes demonstration.
| Table control | Purpose |
|---|---|
| Filter by name | Find a variable in a larger project. Filtering the table does not remove variables. |
| Name | The key used by dynamic references and actions. An adjacent copy control is available for the entry. |
| Type | The value's string, number, or boolean type. Choose a type matching the data and receiving property. |
| Default value | Configure the initial/default value using a text field, number field, or switch. This is not a live equipment-status monitor. |
| External value setter | Configure an incoming value from an existing connector. Use it for feedback from the system. |
| Formatter function | Select an available formatting function when the incoming value needs conversion. |
| Side effect actions | Add actions associated with value changes. These are separate from an element's press actions. |
| Delete | Remove an entry after checking its references. Tokens and actions that still use the name must be updated. |
The table can scroll horizontally when all columns do not fit. Configuration controls may be easier to see when you focus the corresponding cell.
Default and current values
For a numeric volume variable, choose Number and set its default to 25 in the Forms Editor.
The default value initializes the variable; the current value represents its working state. Set defaults through the Forms Editor and test value changes in Live Preview.
Use the Forms Editor for connector and formatter selection.
Attach a dynamic value to an element property
- Select the element in the visual editor and open Element Properties.
- Expand the relevant group, such as Content → Text content.
- Click the property's dynamic-value button (
{}). - In Pick Dynamic Value, choose Global Variables or Parameters.
- Use the All, Boolean, String, or Number filter if needed, then select the intended row.
- Click Attach & Close to apply the selection and return, or Attach to apply it while keeping the picker open. Close leaves without attaching the selected row.
The picker was opened from a Text element's content property. It shows volume selected for illustration. The breadcrumb identifies the page, container, element, and property you are editing; check it before attaching a value.
An attached whole-property value appears as a var or param binding with its name beside it. The picker replaces that property's value with the reference. If you need a prefix, suffix, or several values in one label, use an embedded token instead.
Whole value or text containing a value
| Desired result | Render property value |
|---|---|
| Display the global volume alone | $volume$ |
| Display a label with the global volume | Volume: $volume$ % |
| Display the current page's room name | %roomName% |
| Combine text with a page parameter | Room: %roomName% |
| Select a mode using boolean feedback | $docsLightOn$ in Mode selector by index or name |
Supported render properties include labels, text, image/video sources, colors, placeholders, and mode selectors. Select a value that makes sense for the receiving property: a valid color for a color field, a URL for a media source, and a numeric value for a numeric setting.
An unknown token remains literal. If the interface displays $volume$ instead of a value, check the name and scope before changing the formatting.
Rich-text values
A Text or Button label can contain inline tokens in its rich text, for example:
<p>Room: %roomName%</p>
<p>Volume: $volume$ %</p>
The rich-text toolbar also supports global-variable display tags such as varString, varNumber, and varBoolean. These tags reference global variables. For page parameters in rich text, use %parameterName% tokens. Do not switch between $...$ and %...% based only on a similar-looking name.
Create and pass page parameters
A page parameter makes a reusable page configurable. For example, one room-card page can display Boardroom in one instance and Lobby in another.
- Activate the target
.pagefile in the visual editor. - Run AVstudio: Open page parameters from the Command Palette, or use the page-parameters toolbar button.
- In Page Parameters, click Create new parameter.
- Enter
roomName, choose string, and useRoomas its default. - Save the page and use
%roomName%in the target page's Text element.
Check the file breadcrumb: parameters belong to the active page. The table provides the same default, external setter, formatter, and side-effect action concepts as global variables, but the value's scope is the page instance.
Configure the host Subpage
- Open the page that contains the Subpage element.
- Select the Subpage and set Content → Target Subpage to
catalog/room-card.page. - Expand Input Parameters in Element Properties.
- Set
roomNametoBoardroomfor this instance. - Preview the result and check that the card displays the supplied name.
The host supplies inputParameters with keys matching the target's parameter names. A missing input leaves the target's default available. To vary repeated cards by record, use a Subpage List and map its current-item fields. See Subpages, lists, and global slots.
Read values from an attached datasource
Attach the datasource to the element that consumes it. The token's key must exactly match attachedDatasource.datasource, including the path and extension.
| Token | Meaning |
|---|---|
#datasources/rooms.datasource:name# | Read name from the attached result object |
#datasources/rooms.datasource:0.name# | Read the first array item's name |
#datasources/rooms.datasource:*.name# | Read the current Subpage List record's name in its input mapping |
Paths address the result after the datasource's pick/filter steps. An unknown key, missing path, or not-yet-loaded result can leave the token literal. The exact whole-string datasource token preserves the source value's type; embedding it in text produces text.
In a Subpage List's dynamic picker, All items (N) provides fields for the current-item mapping. The * scope belongs to that list instance. A single Subpage does not gain a current-item scope merely because it has an attached datasource. See Datasources.
Inspect page parameters without opening the parameter editor
The page context menu reports its parameter count, Page Properties shows the full table, and the canvas informer offers Parameters: N. Use that shortcut or Hub → Open Page Parameters to open the parameter editor. Inspect the reusable target page's declarations before mapping host Input Parameters.
Bind incoming equipment feedback
Use External value setter when a connector should update the variable. First create and configure the actual connector; then select it in the Forms Editor and configure its signal, topic, or datapoint.
| Integration | Binding information |
|---|---|
| Crestron | Connector, signal/join name, and boolean/number/string signal type |
| WebSocket | Connector and root-relative JSON path to a scalar; objects/arrays are ignored for variable bindings |
| MQTT | Connector and incoming topic |
| KNX | Connector, datapoint identifier, and matching data-point format |
In the variable’s external setter, select the Crestron connector connectors/processor.crestron, choose a boolean signal, and enter join 1 for this example.
The connector path and signal are placeholders for your actual configuration. The connector file must exist. Match the incoming type to the variable and apply a formatter only when a conversion is needed.
For a lighting indicator, bind the reported state to a boolean variable and use that variable in the element's mode selector. A false value selects Default; true selects the first added mode. Sending a command to turn on a light does not prove it is on: test feedback by changing the equipment state from another controller. See Modes and feedback styling.
Formatter functions and side-effect actions
Formatter function selects a compiled project function by its UID (formatValueFunctionUid). Use a formatter when the incoming representation needs conversion before the value is consumed. Test both normal and unexpected input and ensure the result matches the variable's type. Selecting a function does not establish the connector binding itself.
Side effect actions → Create Action configures behavior associated with a variable or parameter change, typically onChange. For example, a change can trigger an action configured for the receiving system. Review the event and destination carefully; do not unintentionally send the same feedback value back into a loop.
The three concerns are separate: an external setter receives data, a formatter transforms it, and an action performs behavior. A displayed token only reads the value. See Functions and Actions and navigation.
For example, give a status string the default Waiting for device, receive the actual status through its external setter, and display it in a Text element. A formatter can translate the incoming value into the intended label or language. Verify an actual update after startup: the useful default keeps the label readable before feedback arrives, while the external value establishes the reported state.
Environment and system-provided values
Deployment constants use @env:KEY@ from optional env/*.env files. They resolve in render properties, connector configs, project settings, and element/page action fields, but not variable-/parameter-owned action values. See Environment files for selection, typed values, and build behavior.
Subpage List instances receive %avstudio_listItemKey% and %avstudio_listItemIsSelected% from the list automatically. The avstudio_ prefix is reserved; do not create user variables or parameters under it, override the supplied input values, or attach external setters. See Selected-item context.
Render tokens and action fields
Render properties resolve $variable$, %parameter%, and datasource paths. Since 27.0.3, action fields also resolve tokens according to their host scope: element actions support all three; page actions and variable/parameter side effects support variables and parameters. Element/page actions can also resolve Crestron feedback tokens. Use the in-editor dynamic-value modal for action fields and feedback joins; some property workflows retain the separate AVS Dynamic Picker editor.
For an incoming WebSocket scalar, select the connector in External value setter and specify externalBinding.kind: "websocket", connectorName: "connectors/panel.websocket", and path: "payload.temperature". Global variables and page parameters use the same binding shape. Match the target type and test an incoming JSON message in Live Preview.
For value-change actions, choose between the event's changed value and a custom value. See Actions for scope and direct Crestron feedback for property, mode, and subpage bindings.
Boolean page-parameter text
Since 27.0.6, the rich-text toolbar supports boolean page-parameter labels. Use a boolean parameter tag to choose text for each state:
<parameterBoolean name="lightOn" true="Light ON" false="Light OFF"/>
This reads the current page parameter; a global boolean uses varBoolean instead. String values "false" and "0" correctly select the false label. Test both states and the unset/default case. An inline %lightOn% token reads the parameter value without this pair of labels.
Troubleshooting
| Symptom | What to check |
|---|---|
| A token appears as literal text | Check its spelling, delimiters, and actual global/page scope. |
| The value is missing from the picker | Check the Global Variables/Parameters tab, type filter, and active page. |
| A prefix disappeared after attaching a value | The picker attached the whole property. Use an embedded token for mixed text. |
| Every room card shows the same name | Check whether you used a global variable instead of a parameter supplied separately to each instance. |
| The card shows its default | Check the host's Target Subpage and matching Input Parameters keys. |
| A datasource token remains literal | Check the attachment, exact datasource key, filtered result path, and load state. |
*.name does not resolve | Check that the mapping is in the matching Subpage List's item scope. |
| Changing a default does not confirm equipment state | Test the connector's incoming feedback rather than treating the default field as a live monitor. |
An action sends $volume$ as text | Check the extension version, exact variable/parameter scope, token spelling, and action host; datasource scope is element-only. |
| Feedback produces the wrong value | Check connector type, signal/topic/datapoint, variable type, and formatter. |
Verify the setup
- Save the variable or page file and run Run Project Health Check.
- Open Live Preview and check the default text, number, and boolean-driven appearance.
- Change the value through a configured local action and verify every intended consumer updates.
- For reusable pages, provide two different input values and confirm the instances remain independent.
- For hardware feedback, test a state change received from the actual connector, separately from outgoing commands.




