The GenericValue variable is a type of variable that can store any kind of data, including text, numbers, dates, and arrays, and is particular to UiPath Studio.
GenericValue 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 project.
UiPath Studio has an automatic conversion mechanism of GenericValue variables, which you can guide towards the desired outcome by carefully defining their expressions. Take into account that the first element in your expression is used as a guideline for what operation Studio performs. For example, when you try to add two GenericValue variables, if the first one in the expression is defined as a String, the result is the concatenation of the two. If it is defined as an Integer, the result is their sum.
Supported .NET Methods
Name/Syntax | Description |
---|---|
CompareTo | [Click here for details.][1] |
Contains | [Click here for details.][2] Used to check whether a string variable contains a certain substring or not. For example, if you want to check if a sentence contains a specific word, the expression should be Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Equals | [Click here for details.][3] |
GetHashCode | [Click here for details.][5] |
GetType | [Click here for details.][6] |
GetTypeCode | [Click here for details.][7] |
IndexOf | [Click here for details.][8] Used to return the index of a substring contained inside a string variable. For example, if you want to find the index of the word "locate" inside the sentence "Find 'locate' in this sentence", the expression should be Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Length | [Click here for details.][9] Used to return the number of characters in a string variable. For example, if you want to find out how many letters a word has, the expression should be Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Replace | [Click here for details.][10] Used to replace data contained inside a string variable. For example, if you want to change a local file path Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Split | [Click here for details.][11] Used to return individual components from a string variable. For example, if you want to extract the year from a MM.DD.YYYY date format, the expression should be Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Substring | [Click here for details.][12] Used to return a substring contained in a string variable. For example, if you want to extract a word from the "There are 100 machines available" sentence, the expression should be Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
ToBoolean | [Click here for details.][13] |
ToByte | [Click here for details.][14] |
ToChar | [Click here for details.][15] |
ToDecimal | [Click here for details.][17] |
ToDouble | [Click here for details.][18] |
ToInt | Used to convert a specified value to a nullable integer. Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToInt16 | [Click here for details.][20] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToInt32 | [Click here for details.][21] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToInt64 | [Click here for details.][22] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToLower | [Click here for details.][23] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
ToLowerInvariant | [Click here for details.][24] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
ToSByte | [Click here for details.][25] |
ToSingle | [Click here for details.][26] |
ToString | [Click here for details.][27] |
ToType | [Click here for details.][29] |
ToUInt16 | [Click here for details.][30] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToUInt32 | [Click here for details.][31] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToUInt64 | [Click here for details.][32] Note: When using this method with a GenericValue variable of data type Boolean, the "True" and "False" values are converted to 1 and 0, respectively. |
ToUpper | [Click here for details.][33] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
ToUpperInvariant | [Click here for details.][34] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
Trim | [Click here for details.][35] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
TrimEnd | [Click here for details.][36] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
TrimStart | [Click here for details.][37] Note: When using this method with a GenericValue variable of data type Int, Float or Boolean, the data is automatically converted to String and handled accordingly. |
When using Ctrl + K, Ctrl + M, or Ctrl + Shift + M directly in the Format Value activity body, the created variable or argument is of type GenericValue. For other activities, the created type is the same as the required type of the activity.
Example of Using a GenericValue Variable
To demonstrate how a GenericValue variable works, let us create an automation that performs different operations whose results depend on the way we define their expressions. We create two GenericValue variables of different data types and display the results in the Output panel.
- Create a new blank project.
- Create three GenericValue variables:
Int
,Str
, andResult
. - In the Default column for the
Int
variable, type 12, and for theStr
variable, type "34". The first variable is interpreted as an integer, while the second one is interpreted 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
Result
variable. - In the Value field, type
Int
+Str
. - Add a Write Line activity and connect it to the Assign one.
- In the Properties panel, in the Text field, enter the
Result
variable.
The 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.


- Go back to the previously added Assign activity and change the Value field to
Str
+Int
, to reverse the order of the variables. The project should look as in the following screenshot.


- Press F5 to execute your automation. Note that, in the Output panel, the concatenation of the two numbers is displayed.


This means that UiPath Studio takes the first element defined in your expression as a guideline for what operation to perform. If the first element in your expression is an integer or a GenericValue variable filled in as integer, UiPath Studio will perform the sum of the elements.
If the first element in your expression is a string or a GenericValue variable filled in as string, UiPath Studio will perform the concatenation of the elements.
Updated 6 months ago