Skip to main content
Blockly
  • Blockly
Guides Reference Tutorial
  • Codelabs
  • Samples
Summits Community Forum Accessibility
/
  • English
  • Deutsch
  • Español
  • Español – América Latina
  • Français
  • Indonesia
  • Italiano
  • Polski
  • Português – Brasil
  • Tiếng Việt
  • Türkçe
  • Русский
  • עברית
  • العربيّة
  • فارسی
  • हिंदी
  • বাংলা
  • ภาษาไทย
  • 中文 – 简体
  • 中文 – 繁體
  • 日本語
  • 한국어
  • Reference
Blockly
  • Blockly
  • Guides
  • Reference
  • Tutorial
    • More
  • Summits
  • Community Forum
  • Accessibility
  • Overview
  • Classes
  • ASTNode
  • BasicCursor
  • Block
  • BlockSvg
  • CodeGenerator
  • CollapsibleToolboxCategory
  • ComponentManager
  • Connection
  • ConnectionChecker
  • ConnectionDB
  • ContextMenuRegistry
  • Cursor
  • DeleteArea
  • DragTarget
  • FieldCheckbox
  • FieldDropdown
  • FieldImage
  • FieldLabel
  • FieldLabelSerializable
  • FieldNumber
  • FieldTextInput
  • FieldVariable
  • FlyoutButton
  • FlyoutMetricsManager
  • Gesture
  • Grid
  • HorizontalFlyout
  • Input
  • InsertionMarkerManager
  • InsertionMarkerPreviewer
  • Marker
  • MarkerManager
  • Menu
  • MenuItem
  • MetricsManager
  • Names
  • Options
  • RenderedConnection
  • Scrollbar
  • ScrollbarPair
  • ShortcutRegistry
  • TabNavigateCursor
  • Theme
  • ThemeManager
  • Toolbox
  • ToolboxCategory
  • ToolboxItem
  • ToolboxSeparator
  • Trashcan
  • UnattachedFieldError
  • VariableMap
  • VariableModel
  • VerticalFlyout
  • Workspace
  • WorkspaceAudio
  • WorkspaceDragger
  • WorkspaceSvg
  • ZoomControls
  • Abstract Classes
  • Field
  • Flyout
  • Enumerations
  • ConnectionType
  • Functions
  • hasBubble(obj)
  • hideChaff(opt_onlyClosePopups)
  • inject(container, opt_options)
  • isCopyable(obj)
  • isDeletable(obj)
  • isDraggable(obj)
  • isIcon(obj)
  • isPaster(obj)
  • isSelectable(obj)
  • isSerializable(obj)
  • isVariableBackedParameterModel(param)
  • setLocale(locale)
  • Interfaces
  • BlocklyOptions
  • FieldCheckboxConfig
  • FieldCheckboxFromJsonConfig
  • FieldConfig
  • FieldDropdownFromJsonConfig
  • FieldImageConfig
  • FieldImageFromJsonConfig
  • FieldLabelConfig
  • FieldLabelFromJsonConfig
  • FieldNumberConfig
  • FieldNumberFromJsonConfig
  • FieldTextInputFromJsonConfig
  • FieldVariableConfig
  • FieldVariableFromJsonConfig
  • IASTNodeLocation
  • IASTNodeLocationSvg
  • IASTNodeLocationWithBlock
  • IAutoHideable
  • IBoundedElement
  • IBubble
  • ICollapsibleToolboxItem
  • IComponent
  • IConnectionChecker
  • IConnectionPreviewer
  • IContextMenu
  • ICopyable
  • IDeletable
  • IDeleteArea
  • IDraggable
  • IDragger
  • IDragStrategy
  • IDragTarget
  • IFlyout
  • IHasBubble
  • IIcon
  • IKeyboardAccessible
  • IMetricsManager
  • IMovable
  • IPaster
  • IPositionable
  • IRegistrable
  • ISelectable
  • ISelectableToolboxItem
  • ISerializable
  • IStyleable
  • IToolbox
  • IToolboxItem
  • IVariableBackedParameterModel
  • Namespaces
  • ASTNode
  • Block
  • blockAnimations
  • blockRendering
  • browserEvents
  • bubbles
  • bumpObjects
  • clipboard
  • CollapsibleToolboxCategory
  • comments
  • common
  • ComponentManager
  • constants
  • ContextMenu
  • ContextMenuItems
  • ContextMenuRegistry
  • Css
  • dialog
  • dragging
  • Events
  • Extensions
  • fieldRegistry
  • geras
  • icons
  • ICopyable
  • inputs
  • InsertionMarkerManager
  • libraryBlocks
  • MetricsManager
  • Names
  • Options
  • Procedures
  • registry
  • RenderedConnection
  • renderManagement
  • serialization
  • ShortcutItems
  • ShortcutRegistry
  • Theme
  • ThemeManager
  • Themes
  • thrasos
  • ToolboxCategory
  • ToolboxSeparator
  • Tooltip
  • Touch
  • uiPosition
  • utils
  • Variables
  • VariablesDynamic
  • WidgetDiv
  • Xml
  • zelos
  • Variables
  • Blocks
  • COLLAPSE_CHARS
  • COLLAPSED_FIELD_NAME
  • COLLAPSED_INPUT_NAME
  • config
  • defineBlocksWithJsonArray
  • DELETE_VARIABLE_ID
  • DropDownDiv
  • getMainWorkspace
  • getSelected
  • INPUT_VALUE
  • JavaScript
  • Msg
  • NEXT_STATEMENT
  • OPPOSITE_TYPE
  • OUTPUT_VALUE
  • PREVIOUS_STATEMENT
  • PROCEDURE_CATEGORY_NAME
  • RENAME_VARIABLE_ID
  • setParentContainer
  • svgResize
  • TOOLBOX_AT_BOTTOM
  • TOOLBOX_AT_LEFT
  • TOOLBOX_AT_RIGHT
  • TOOLBOX_AT_TOP
  • VARIABLE_CATEGORY_NAME
  • VARIABLE_DYNAMIC_CATEGORY_NAME
  • VERSION
  • Type Aliases
  • FieldCheckboxValidator
  • FieldDropdownConfig
  • FieldDropdownValidator
  • FieldNumberValidator
  • FieldTextInputConfig
  • FieldTextInputValidator
  • FieldValidator
  • FieldVariableValidator
  • ICopyData
  • MenuGenerator
  • MenuGeneratorFunction
  • MenuOption
  • Codelabs
  • Samples
  • Home
  • Products
  • Google for Education
  • Blockly
  • Reference

blockly > Workspace > getVariableById

Workspace.getVariableById() method

Find the variable by the given ID and return it. Return null if not found.

Signature:

getVariableById(id: string): VariableModel | null;

Parameters

Parameter Type Description
id string The ID to check for.

Returns:

VariableModel | null

The variable with the given ID.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-09-18 UTC.

  • Programs

    • Google Developer Groups
    • Google Developer Experts
    • Accelerators
    • Women Techmakers
  • Developer consoles

    • Google API Console
    • Google Cloud Platform Console
    • Google Play Console
    • Firebase Console
    • Actions on Google Console
    • Cast SDK Developer Console
    • Chrome Web Store Dashboard
Google Developers
  • Android
  • Chrome
  • Firebase
  • Google Cloud Platform
  • All products
  • Terms
  • Privacy
  • ICP证合字B2-20070004号
  • Manage cookies
  • Sign up for the Google Developers newsletter Subscribe
  • English
  • Deutsch
  • Español
  • Español – América Latina
  • Français
  • Indonesia
  • Italiano
  • Polski
  • Português – Brasil
  • Tiếng Việt
  • Türkçe
  • Русский
  • עברית
  • العربيّة
  • فارسی
  • हिंदी
  • বাংলা
  • ภาษาไทย
  • 中文 – 简体
  • 中文 – 繁體
  • 日本語
  • 한국어