Unify Logo Footer.svg
Unify Applications
Logo
Data & Variable Actions

Data & Variable Actions

Logo

5 mins READ

Actions at a Glance

Action TypeBuilder LabelUse When
controlDataSourceTrigger Data SourceRe-run or refresh a data source on demand
setPageVariableControl VariableRead and write a page or app variable
setURLParametersSet URL ParametersUpdate the current page's query string without navigating
setLocalStorageControl Local StoragePersist a value that survives page reloads and sessions
setInterfaceSessionStorageControl Session StoragePersist a value for the current browser session only

controlDataSource — Trigger Data Source

Re-runs a data source (a query or API binding on the page) on demand. Use it after a record is created, updated, or deleted to refresh bound blocks with fresh data, or to manually kick off a data source configured with Manual run behavior.

Parameters

ParameterTypeRequiredDefaultDescription
dataSourceIdstringRequired (required)The ID of the data source to trigger. Pick from the builder's data source dropdown. If omitted, the action silently does nothing.
method"trigger" | "cancel"Optional (optional)"trigger"trigger runs/re-runs the data source. cancel aborts any in-progress request.

Tip: Pattern: Wire controlDataSource on the success callback of a mutation action (create, update, delete) to keep the list fresh without a full page reload.

Examples

Refresh a data source after creating a record

{ "actionType": "controlDataSource", "payload": { "dataSourceId": "ds_listOrders", "method": "trigger" } }

Cancel an in-flight request when user navigates away

{ "actionType": "controlDataSource", "payload": { "dataSourceId": "ds_longReport", "method": "cancel" } }

setPageVariable — Control Variable

Reads or writes a page variable or app variable. Variables are reactive in-memory slots — every block or expression bound to the variable re-evaluates immediately when a write lands. The available operations depend on the variable's declared type.

Parameters

ParameterTypeRequiredDefaultDescription
variableIdstringRequired (required)The ID of the variable to write (var_…). Picked from the builder's variable selector. If the variable no longer exists, the write is silently skipped.
operationstring enumRequired (required)The write operation. Available operations depend on the variable's declared type — see the table below.
valueanyDepends on operationThe value to apply. Supports bindings. For operations like TOGGLE or REMOVE_FIRST, no value is needed.

Operations by Variable Type

Variable TypeAvailable Operations
stringSET, APPEND (add to end), PREPEND (add to beginning)
numberSET, INCREMENT_BY, DECREMENT_BY
booleanSET, TOGGLE
objectSET, MERGE (shallow merge), REMOVE_PROPERTY
arraySET, APPEND, PREPEND, REMOVE_LAST, REMOVE_FIRST, REMOVE_AT (by index), REMOVE_BY_VALUE

Warning: Type gates operations. Using INCREMENT_BY on a string variable will fail silently — the value keeps its previous state. Numeric operations reject non-numeric input. Object MERGE is shallow — a nested object replaces rather than deep-merges.

Examples

Set a string variable

{ "actionType": "setPageVariable", "payload": { "variableId": "var_status", "operation": "SET", "value": "active" } }

Toggle a boolean variable (show/hide a panel)

{ "actionType": "setPageVariable", "payload": { "variableId": "var_showPanel", "operation": "TOGGLE" } }

Increment a counter on each click

{ "actionType": "setPageVariable", "payload": { "variableId": "var_clickCount", "operation": "INCREMENT_BY", "value": 1 } }

Add an item to a cart array

{ "actionType": "setPageVariable", "payload": { "variableId": "var_cartItems", "operation": "APPEND", "value": "{{ row.productId }}" } }

Merge new fields into an object variable

{ "actionType": "setPageVariable", "payload": { "variableId": "var_filters", "operation": "MERGE", "value": { "status": "{{ select_status['value'] }}", "page": 1 } } }

setURLParameters — Set URL Parameters

Updates query parameters in the current page's URL without navigating. The URL changes but the page stays mounted — ideal for reflecting filter or tab state in the address bar so users can share or bookmark the current view.

Parameters

ParameterTypeRequiredDefaultDescription
paramsobjectRequired (required)Key-value pairs to write into the URL query string. Values support bindings. Existing params not mentioned are preserved.
history"push" | "replace"Optional (optional)"replace"Whether to add a new browser history entry or replace the current one.

Sync active tab to URL

{ "actionType": "setURLParameters", "payload": { "params": { "tab": "{{ tabs_main['activeTab'] }}" }, "history": "replace" } }

setLocalStorage — Control Local Storage

Reads or writes a value in the browser's localStorage. Local storage persists across browser sessions — it survives page reloads, closing the tab, and reopening the browser. Use it for user preferences or remembered state that should persist indefinitely on the device.

Parameters

ParameterTypeRequiredDefaultDescription
keystringRequired (required)The storage key to read/write. Use unique keys to avoid collisions between apps or pages.
operation"SET" | "REMOVE"Required (required)SET writes value to the key. REMOVE deletes the key from storage.
valueanyRequired for SETThe value to store. Objects are serialized to JSON. Supports bindings.

Remember a user's preferred theme

{ "actionType": "setLocalStorage", "payload": { "key": "app_preferred_theme", "operation": "SET", "value": "{{ select_theme['value'] }}" } }

Read local storage value in a binding

{{ localStorage['app_preferred_theme'] }}

setInterfaceSessionStorage — Control Session Storage

Reads or writes a value in the browser's sessionStorage. Session storage persists for the duration of the browser session — it is cleared when the tab is closed, but survives page reloads within the same session. Use it for temporary state like form drafts or wizard progress that should not persist between sessions.

Parameters

ParameterTypeRequiredDefaultDescription
keystringRequired (required)The session storage key to read/write.
operation"SET" | "REMOVE"Required (required)SET writes the value; REMOVE deletes the key.
valueanyRequired for SETThe value to store. Supports bindings. Objects are serialized to JSON.

Save wizard step progress in session storage

{ "actionType": "setInterfaceSessionStorage", "payload": { "key": "onboarding_step", "operation": "SET", "value": "{{ stepper_onboarding['currentStep'] }}" } }

Choosing the Right Storage Mechanism

MechanismScopePersistsUse For
Page VariableSingle pageUntil page unmounts (navigation)UI state, selections, form drafts within a page
App VariableWhole app sessionUntil browser reload or new tabState that must survive in-app navigation
URL ParametersCurrent page URLShareable in the URLFilter state, active tab, pagination — shareable/bookmarkable
Session StorageBrowser tab/sessionUntil tab is closedWizard progress, draft data, temporary preferences
Local StorageBrowser (device)Indefinitely (until cleared)Theme preference, language, long-lived user settings