The generic value variable is a type of variable with a wide range that can store any kind of data, including text, numbers, dates and arrays, and is particular to UiPath Studio.
Generic value variables are automatically converted to other types, in order to perform certain actions. However, it is important to use these types of variables carefully, as their conversion may not always be the correct one for your automation.
To demonstrate how a generic value variable can be converted and used, let us create a project that displays the sum of two numbers in the Output panel, using generic value variables with different types of values.
- Create a Flowchart.
- Create three generic value variables,
- In the Default column for the
genNumbervariable, type 2, and for the
genStringvariable, type "2." The first variable is interpreted as an integer, and the second one as a string.
- Add an Assign activity to the Designer panel and connect it to the Start node.
- In the Properties panel, in the To field, enter the
- In the Value field, type
- Add a Write Line activity and connect it to the Assign one.
- In the Properties panel, in the Text field, enter the
The final project should look as in the following screenshot.
- Press F5 to execute your automation. Note that, in the Output panel, the sum of the two numbers is displayed.
This means that UiPath Studio knows that the
genNumber is an integer and knows how to transform the generic value
genString variable to an integer, so that it can add it to the first one.
However, keep in mind that this was our goal from the beginning. If we wanted to display the two variables in the Output panel as strings using this exact method, it would not have worked.
Updated 4 years ago