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.
- On the Design ribbon tab, in the Variables group, select Create Variable > [Type of variable]. The Create Variable window is displayed.
- Fill in the required fields and click OK. The variable is created and you can view and edit it in the Variables panel.
- 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 activities 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 not used in your currently opened project:
- On the Design ribbon tab, in the Variables group, select Manage Variables > Remove Unreferenced. Note that the Variables panel only contains the variables used in your automation.
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.
Some variables, when created directly in an activity (from the context menu of an activity), are automatically given the smallest scope they belong to. To make them available in your entire project, do the following:
- Click the smallest container in an automation.
- On the Design ribbon tab, in the Variables group, select Manage Variables > Promote to Global Scope. All the variables used in the selected container now have a global scope.