In UiPath 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. You can check out our Workflow Design Naming Conventions recommendations.
The data stored within a variable is called a value, and it can be of multiple types. In UiPath, we support a large amount of types, ranging from generic value, text, number, data table, time and date, UiElements to any .Net variable type.
Variables cannot be created if the Designer panel does not contain at least one activity.
- In the Properties panel of any activity, right-click a field that can be edited, and select Create Variable from the context menu, or press Ctrl+K. A Set Name field is displayed.
- Fill in the name and press Enter. The variable is created and you can view and edit it in the Variables panel. The scope of variables created like this always belongs to the smallest container it is part of.
When creating variables like this, the type is automatically generated, depending on the selected property.
- In the Designer panel, click Variables. The Variables panel is displayed.
- Click the Create Variable line. A new variable with the default values is displayed.
By default, all new variables are of String type if you create them from the Variables panel.
- In the Variable panel, right-click a variable and select the Delete option.
- In the Variable panel, select a variable and press the Delete key.
If you want to undo this action, press Ctrl+Z.
You can also remove all the variables that are defined in the Variables panel, but not used in your currently opened project.
To do so on the Design ribbon tab, in the Variables group, select Remove Unused Variables. This also removes variables that are unused, but mentioned in annotations.
If you remove or upgrade a package that may lead to a variable or argument being undefined, an Unknown Type is added in its place so that the file can be opened and edited in Studio.
To search for types of variables that are not displayed by default in the Variable Type list, do the following:
- In the Variable panel, from the Variable Type drop-down list, select Browse for Types. 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.
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.