UiPath Studio Guide

Managing Variables

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.

Note:

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.

Creating Variables

Note:

Variables cannot be created if the Designer panel does not contain at least one activity.

From the Design ribbon tab:

  1. On the Design ribbon tab, in the Variables group, select Create Variable > [Type of variable]. The Create Variable window is displayed.
  1. Fill in the required fields and click OK. The variable is created and you can view and edit it in the Variables panel.

From the context menu or with a keyboard shortcut (Ctrl+K):

  1. 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.
  2. 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.

Note:

When creating variables like this, the type is automatically generated, depending on the selected property.

From the Variables panel:

  1. In the Designer panel, click Variables. The Variables panel is displayed.
  2. Click the Create Variable line. A new variable with the default values is displayed.

Note:

By default, all new variables are of String type if you create them from the Variables panel.

Removing Variables

  • 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.

Note:

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:

  1. 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.

Browsing for .Net Variable Types

To search for types of variables that are not displayed by default in the Variable Type list, do the following:

  1. 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.
  2. 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.
  3. 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.

Promoting Variables to Global Scope

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:

  1. Click the smallest container in an automation.
  2. 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.

Managing Variables