The four variable scopes in VBCS
VBCS organises variables in a hierarchy: Application → Flow → Page → Component. Each scope has different lifetime, visibility, and appropriate use cases.
Application-level variables
Persistent for the entire session. Accessible from any page or flow. Use for:
- Currently logged-in user details
- Application-wide settings (locale, theme preference)
- Reference data that doesn’t change during a session (currency codes, status maps)
- Feature flags
Don’t overuse: every application variable consumes memory for the full session. Large arrays or objects at app scope can noticeably increase memory usage.
Flow-level variables
Shared across all pages within the same flow. Reset when the user leaves the flow. Use for:
- Multi-step wizard state (data entered in step 1 needed in step 3)
- Shared filter state for a group of related pages
- Cross-page context (e.g. selected record that multiple pages act on)
Page-level variables
Available only on the current page. Destroyed when the user navigates away. Use for:
- Form input bindings
- Table data and pagination state
- Loading and error flags
- Computed display values
The majority of your variables should be page-level. If something is only needed on one page, it belongs here.
Component/event-level variables
Scoped to a single component instance or event handler. Use for:
- Temporary values inside action chains (intermediate calculation results)
- Event-specific context that doesn’t need to outlive the action
Common mistakes
Putting everything at app level: convenient but causes stale data bugs. Page A sets a variable; the user navigates to Page B, navigates back to Page A — the stale value is still there.
Flow variables for page-specific data: flow variables persist as users move between pages in the flow. If Page 2 modifies a flow variable expecting it to be reset when re-entering Page 2, it won’t be — flow variables reset only when leaving the flow entirely.
Large arrays as page variables bound to tables: page variables holding a 10,000-row array render slowly. Paginate and fetch incrementally instead.
Type discipline
Define variable types explicitly — don’t rely on Any. An untyped variable that receives unexpected structure causes hard-to-debug binding failures. Define object types with all expected fields, even if some are optional.