- Release Notes
- Getting Started
- Setup and Configuration
- Automation Projects
- Dependencies
- Types of Workflows
- File Comparison
- Automation Best Practices
- Source Control Integration
- Debugging
- The Diagnostic Tool
- Workflow Analyzer
- About Workflow Analyzer
- ST-NMG-001 - Variables Naming Convention
- ST-NMG-002 - Arguments Naming Convention
- ST-NMG-004 - Display Name Duplication
- ST-NMG-005 - Variable Overrides Variable
- ST-NMG-006 - Variable Overrides Argument
- ST-NMG-008 - Variable Length Exceeded
- ST-NMG-009 - Prefix Datatable Variables
- ST-NMG-011 - Prefix Datatable Arguments
- ST-NMG-012 - Argument Default Values
- ST-NMG-016 - Argument Length Exceeded
- ST-DBP-002 - High Arguments Count
- ST-DBP-003 - Empty Catch Block
- ST-DBP-007 - Multiple Flowchart Layers
- ST-DBP-020 - Undefined Output Properties
- ST-DBP-023 - Empty Workflow
- ST-DBP-024 - Persistence Activity Check
- ST-DBP-025 - Variables Serialization Prerequisite
- ST-DBP-026 - Delay Activity Usage
- ST-DBP-027 - Persistence Best Practice
- ST-DBP-028 - Arguments Serialization Prerequisite
- ST-USG-005 - Hardcoded Activity Arguments
- ST-USG-009 - Unused Variables
- ST-USG-010 - Unused Dependencies
- ST-USG-014 - Package Restrictions
- ST-USG-020 - Minimum Log Messages
- ST-USG-024 - Unused Saved for Later
- ST-USG-025 - Saved Value Misuse
- ST-USG-026 - Activity Restrictions
- ST-USG-027 - Required Packages
- ST-USG-028 - Restrict Invoke File Templates
- ST-USG-032 - Required Tags
- ST-USG-034 - Automation Hub URL
- Variables
- Managing Variables
- The Variables Panel
- Types of Variables
- UiPath Proprietary Variables
- Arguments
- Imported Namespaces
- Recording
- UI Elements
- Control Flow
- Selectors
- Object Repository
- Data Scraping
- Image and Text Automation
- Citrix Technologies Automation
- RDP Automation
- Salesforce Automation
- SAP Automation
- VMware Horizon Automation
- Logging
- The ScreenScrapeJavaSupport Tool
- The WebDriver Protocol
- Test Suite - Studio
- Extensions
- Troubleshooting
- About troubleshooting
- Microsoft App-V support and limitations
- Internet Explorer X64 troubleshooting
- Microsoft Office issues
- Identifying UI elements in PDF with Accessibility options
- Repairing Active Accessibility support
- Automating Applications Running Under a Different Windows User
- Validation of large Windows-legacy projects takes longer than expected
Managing Variables
In Studio, variables are used to store multiple types of data. Another key aspect of variables is that their value can change so that you can, for example, control how many times the body of a loop is executed.
- Variables need to be created with different names, even if used in different scopes. If two variables share the same name but are in different scopes, the variable in the inner scope takes precedence. You can check out our Workflow Design Naming Conventions recommendations.
- Variable names must start with a letter or underscore
_
. - Using certain keywords (for example, "Replace") to name variables may cause unexpected errors.
.xaml
files based on the loaded activities. All strings have to be placed between quotation marks.
You can manage variables in multiple ways. To benefit from the best experience and flexibility, we recommend using the Data Manager.
The data stored within a variable is called a value, and it can be of multiple types. When you create a variable. the following options are available:
- Boolean - This type has only two possible values:
true
orfalse
. These variables enable you to make decisions, and therefore have a better control over your workflow. - Int32 - This type is used to store numeric information. Some of its uses are to perform equations, comparisons and pass important data.
- String - Stores text information. This type of variable can be used to store any text-based information such as employee names, usernames or any other strings.
- Object - Can be used to store different types of data. You can use this type of variable in situations where you need flexibility for the type of data you store in a variable. Make sure that the data type used in Object variables is compatible with the activities that use the variable.
- System.Data.DataTable - This type can store big pieces of information, and act as a database or a simple spreadsheet with rows and columns. Can be useful to migrate specific data from a database to another and extract information from a website and store it locally in a spreadsheet, among other uses.
- Array of [T] - Enables you to store multiple values of the same type.
-
Browse for Types - Allows you to explore more types that can be relevant to your task.
Note: Using variables of types defined by the language used in the project as static results in a compilation error in Windows and cross-platform projects.
The scope property gives variables a well-defined context in which they can be used. The scope can be set to global (available in the entire project), the current workflow file, or any container activity within the workflow file.
You can only create global variables from the Data Manager.
- Global variables are not serializable, and therefore incompatible with long-running persistence activities.
- Global variables are not supported in library projects.
- Open the Data Manager, then select New > New Variable.
- Configure the name, data type, scope, and default value for the variable.
- From the Activities panel, drag an activity to the Designer panel. Either right-click a field and select Create Variable from the context menu, press Ctrl+K, or select Create Variable from the Plus menu on the right side of the field. The Set Var field is displayed.
- Fill in the name and press Enter. The variable is created and visible in the field. Check its scope and type in the Data Manager.
From Expressions
Alternatively, variables can be created from expressions directly in an activity input field or the Expression Editor:
- Select a part of the expression and press Ctrl+K. The Set Var field is displayed.
-
Fill in the name and press Enter. The variable is created. Check its scope and type in the Data Manager.
Data Table
field of a Write Range activity, the variable's type is set to DataTable
. If you create a variable in the Text
field of a Write Line activity, the variable's type is set to String
.
The scope of such variables is the smallest container it is part of. The type is automatically generated depending on the selected property.
- In the Properties panel of any activity, either right-click a field and select Create Variable from the context menu, press Ctrl+K, or select Create Variable from the Plus menu on the right side of the field. The Set Var field is displayed.
- Fill in the name and press Enter. The variable is created and visible in the field. Check its scope and type in the Data Manager.
The scope of variables created in this way is the smallest container it is part of. The type is automatically generated depending on the selected property.
You can remove variables from the Data Manager or from the Variables panel.
- Open the Data Manager and expand the *Variables node.
- Right-click a variable, and then select Delete Variable. Alternatively, select it and press the Delete key.
- Open the Variables panel.
-
Right-click a variable, and then select Delete. Alternatively, select it and press the Delete key.
To remove all the variables that are defined but not used anywhere in the current file, select Remove Unused > Variables in the Studio ribbon, and then select Yes when prompted for confirmation. This also removes variables that are unused but mentioned in annotations.
To search for types of variables that are not displayed by default in the Variable Type list, do the following:
- In the Data Manager, from the Data Type dropdown for a variable, select Browse for Types. You can also access the menu from the Variable Type dropdown in the Variables panel. The Browse and Select a .Net Type window is displayed.
- In the Type Name field, type a keyword for the variable you are looking for, such as excel. Note that the result section is updated, displaying all the .Net variable types that contain your keyword.
-
Select one and click OK. A new variable is created with the selected type and is displayed in the Variables panel.
Note: After first using a type of variable from the Browse and Select a .Net Type window, it is displayed in the Variable Type drop-down list, in the Variables panel.
Variable and argument types part of assemblies proprietary to Studio or Robot are hidden. Workflows that reference types from such assemblies should not be affected at runtime. To use a type from a non-.Net framework assembly, add it as a dependency to your project with the help of the Manage Packages window.