Data Manipulation includes dealing withvarious variables and performing operations with them. UiPath Studio offers a wide range of variables to support automation: –
- Text variables: – This type of variable can store only string data type and is enclosed in double quotes. You can define the type as “System.String” to declare this kind of variable.
- True or False variables: – This type of variable stores only two possible values – true or false and supports Boolean data type. You can define the types as “System.Boolean” to declare this kind of variable. Make use of this data type when working with flow decisions in Studio.
Number variables: – This type of variable stores numeric data and supports Integer values. You can define the type as “Int32” to declare this kind of variable. Use the “.ToString” method to convert the integer variable to a string and display as such.
- Array variables: – This type of variable will allow you to store a fixed number of multiple values of the same data type, i.e. you can declare an array of number variables (System.Int32), an array of string variables (System.String), an array of Boolean variables (System.Boolean) and so on. Use the Select Types window to declare an array of your choice.
To access all the values you store in an array, give a reference of index in the output. For example, to retrieve the first name from the arrStrnames variable, write line as arrStrNames(0)
List variables: – This type of variable will allow you to store a varying number of multiple values of the same data type. For example, you can declare a list of strings as – System.Collections.Generic.List<System.String>
- Dictionary variables: – A dictionary is an array which can hold a varying number of elements associated with a key-value format. The value is retrieved from the defined key in the variable. To declare a dictionary variable, use “System.Collections. Generic.Dictionary<System.String,System.String>” as the data type.
- Date and Time variables: – This type of variable stores information about any date and time. Declaration is done by using “System.DateTime” as the data type. The default format used is “day.hh:mm:ss”. You can modify the format to only retrieve a particular component.
- Data table variables: – This variable can store information in a database or a simple spreadsheet consisting of rows and columns. Declare this kind of variable by using “System.Data.DataTable”. You can make use of this variable when dealing with excel/workbook automation.
- Generic-Value variables: – This variable can store any kind of data such as numbers, text, dates, arrays, etc. Use this data type when unsure of the exact structure of data you are dealing with. Declare using “UiPath.Core.GenericValue” data type.
String Manipulation in UiPath
UiPath offers a wide range of functions that can be used to perform operations on strings. Details to each are as below:
- Split: This function will divide the string into two parts based on the split identifier mentioned. For an example, take a string “str” as “My:name:is” and define the slit function as – “Split(str,”:”). This will split the string in three different sections based on “:” and to retrieve any one section, you can refer to the output by an index as done in an array.
- Substring: This function lets you customize your division of the entire string.
- Trim: This function removes the leading spaces (Ltrim), trailing spaces(RTrim) or leading and trailing spaces (Trim) from a string. Use this function as – Trim(yourstring), LTrim(yourstring), RTrim(yourstring).
- Replace: This function allows you to replace a character with another character specified. Here “:” gets replaced with “_”
Remove: This function removes the text specified. It can be understood as an inverse operation to substring.
• Left: This function outputs the text from the left side of the variable value.
- Right: This function outputs the text from the right side of the variable value.
- Regex.Replace: This function will replace an expression combination according to the regex specified with a character. Here, “\d” is used as a regular expression to find digit combinations only and then they are replaced by an underscore “_”.