Chapter - 5 Data Elements

25 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€95.03
List Price:  €133.05
You save:  €38.01
£79.15
List Price:  £110.82
You save:  £31.66
CA$139.67
List Price:  CA$195.55
You save:  CA$55.87
A$153.55
List Price:  A$214.98
You save:  A$61.42
S$134.39
List Price:  S$188.16
You save:  S$53.76
HK$778.22
List Price:  HK$1,089.54
You save:  HK$311.32
CHF 88.36
List Price:  CHF 123.71
You save:  CHF 35.34
NOK kr1,105.21
List Price:  NOK kr1,547.34
You save:  NOK kr442.12
DKK kr708.87
List Price:  DKK kr992.45
You save:  DKK kr283.57
NZ$170.45
List Price:  NZ$238.64
You save:  NZ$68.18
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,959.01
List Price:  ৳16,743.10
You save:  ৳4,784.08
₹8,452.40
List Price:  ₹11,833.70
You save:  ₹3,381.29
RM446.45
List Price:  RM625.05
You save:  RM178.60
₦168,042.19
List Price:  ₦235,265.79
You save:  ₦67,223.60
₨27,819.88
List Price:  ₨38,948.94
You save:  ₨11,129.06
฿3,466.55
List Price:  ฿4,853.31
You save:  ฿1,386.76
₺3,454.83
List Price:  ₺4,836.90
You save:  ₺1,382.07
B$580.99
List Price:  B$813.41
You save:  B$232.42
R1,812.36
List Price:  R2,537.39
You save:  R725.02
Лв185.85
List Price:  Лв260.20
You save:  Лв74.35
₩140,106.88
List Price:  ₩196,155.24
You save:  ₩56,048.35
₪373.41
List Price:  ₪522.79
You save:  ₪149.38
₱5,905.80
List Price:  ₱8,268.36
You save:  ₱2,362.56
¥15,438.71
List Price:  ¥21,614.81
You save:  ¥6,176.10
MX$2,034.25
List Price:  MX$2,848.03
You save:  MX$813.78
QR364.93
List Price:  QR510.92
You save:  QR145.98
P1,367.12
List Price:  P1,914.02
You save:  P546.90
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£4,964.56
List Price:  E£6,950.58
You save:  E£1,986.02
ብር12,476.97
List Price:  ብር17,468.25
You save:  ብር4,991.28
Kz91,223.61
List Price:  Kz127,716.70
You save:  Kz36,493.09
CLP$97,372.26
List Price:  CLP$136,325.06
You save:  CLP$38,952.80
CN¥724.09
List Price:  CN¥1,013.76
You save:  CN¥289.66
RD$6,035.83
List Price:  RD$8,450.41
You save:  RD$2,414.57
DA13,357.64
List Price:  DA18,701.23
You save:  DA5,343.59
FJ$226.99
List Price:  FJ$317.80
You save:  FJ$90.80
Q772.55
List Price:  Q1,081.60
You save:  Q309.05
GY$20,937.04
List Price:  GY$29,312.70
You save:  GY$8,375.65
ISK kr13,828.61
List Price:  ISK kr19,360.61
You save:  ISK kr5,532
DH999.72
List Price:  DH1,399.66
You save:  DH399.93
L1,820.82
List Price:  L2,549.22
You save:  L728.40
ден5,848.08
List Price:  ден8,187.54
You save:  ден2,339.46
MOP$802.33
List Price:  MOP$1,123.29
You save:  MOP$320.96
N$1,815.10
List Price:  N$2,541.22
You save:  N$726.11
C$3,682.57
List Price:  C$5,155.75
You save:  C$1,473.17
रु13,507.81
List Price:  रु18,911.48
You save:  रु5,403.66
S/379.77
List Price:  S/531.69
You save:  S/151.92
K402.86
List Price:  K564.02
You save:  K161.16
SAR375.38
List Price:  SAR525.55
You save:  SAR150.16
ZK2,769.51
List Price:  ZK3,877.43
You save:  ZK1,107.91
L472.94
List Price:  L662.13
You save:  L189.19
Kč2,407.85
List Price:  Kč3,371.09
You save:  Kč963.24
Ft39,078.98
List Price:  Ft54,712.13
You save:  Ft15,633.15
SEK kr1,102.90
List Price:  SEK kr1,544.10
You save:  SEK kr441.20
ARS$100,263.16
List Price:  ARS$140,372.43
You save:  ARS$40,109.27
Bs693
List Price:  Bs970.23
You save:  Bs277.22
COP$441,313.30
List Price:  COP$617,856.28
You save:  COP$176,542.97
₡50,820.06
List Price:  ₡71,150.12
You save:  ₡20,330.05
L2,528.86
List Price:  L3,540.51
You save:  L1,011.64
₲783,733.33
List Price:  ₲1,097,258.01
You save:  ₲313,524.68
$U4,278.05
List Price:  $U5,989.44
You save:  $U1,711.39
zł413.19
List Price:  zł578.49
You save:  zł165.29
Already have an account? Log In

Transcript

Chapter Four, data variables and types. In this chapter, we'll give an overview of what data variables and types are. We'll go through primitive data types. We'll also define what variable scope is. And we'll also talk about arguments and importing namespaces. Over overview of data variables, just like other software programming languages, variables are used in UiPath.

For automations. Variables are entities or data items that can store some value within them. This value can be changed, or you know can be displayed are performed computations upon depending on the business logic that you're implementing. Variable simply refers to the name given to a memory location, which is processed and retrieved during execution of a workflow as per its users needs. So, in here we have provided a few variables like the ones that are shown in here you can see data types, each data type has been assigned a variable right. So, this type defines the nature of value, a variable is permissible to hold.

Various types of data are supported in UiPath, like you know integers, strings, date times, Boolean values, etc, etc. Default, default value as the name itself suggests, is a value which is assigned to a variable as soon as it is created. Right and this is set in here. scope. A data scope simply defines the boundary of a variable where it can be accessed by the activities and computers further. Beyond that scope, that variable is invisible for activities.

So, in UiPath, you know, we define the scope when we are creating the variable itself. A quick example would be, say this integer variable has a scope of flowchart, which means the whole flowchart or any activities within the flowchart can actually see this variable. But imagine we have a sequence, right. And this integer variable has a scope of sequence. That means, only within the sequence we can access this integer variable and outside it, we this integer variable becomes invisible. We can't see it anymore.

So, this is for production of the data items. If there's some data that is critical to one particular sequence or one particular part of a workflow itself, then that's where the scope is used. primitive data types there are like, literally hundreds or probably thousands of dead types that are supported in UiPath. And you can see that in here, browse for types. Because UiPath is based on dotnet programming framework. So all the data types are supported in here, all the dotnet data types.

But we have about six or seven primitive data types that usually accomplish most of the tasks that we're trying to automate or like are used within the those tasks. So integer datatype is first, right. Let me create the variable because I just put it to flowchart just because I'm keeping it as a global variable as it is available to the whole flowchart itself. So indeed, your variable, right, it is, as the name itself tells you, this data type is used to store numeric values and both Positive and negative integers are supported within this within this data type. And it ranges from like 2,147,000,000 something something value from negative to positive both. So a lot of values or pretty much any value is supported in detail variables.

A quick example would be, say in this integer variable, we already have assigned a value of 62 as default, so what we can do is if you want to print the value of this variable in a, you know, no ms window right window should pop up. Once we execute the program displaying the value of this integer variable, then we can use this messagebox activity and we can type in our variable name. Once we start typing the name, right, you can see that automatically the UiPath gave the drop down that said that, you know, are you talking about this variable? And yes, you can select it that way it becomes handy too. Use the variables within the activities. Now, there is some sort of compiler error in here.

And to give an overview of this, it says that there is some con conversion that it's trying to do between integer and string it cannot, the system cannot itself do the because to make a message displayable it has to be of string datatype. So, what we're going to do is via use a dot operator and we are going to change this to string which is again a predefined function in dotnet as well as in UiPath. So, once you have that as to string, you can go to your main program, you will simply run it and see that the value of the first of the variable 62 is being displayed. Perfect. Similarly, we have string data type, as we discussed just now is used to store you know multiple alphanumeric characters and one thing to know In string variables is that the value of a string variable is always enclosed in double quotes.

That's because imagine that you know, you have a value of 62, right? Being an integer, the UI path doesn't need to just store a value, it also probably need to perform some computations on it, right? And string has different operations that can be performed on it, like concatenation splitting a string and stuff. And for integers, we would want to do some algorithmic algorithmic operators, like, you know, addition, subtraction, multiplication, division and all that stuff. So to differentiate between the two string is always enclosed in double quotes, to say that it is sort of a message, right? That's how we do in the message box as well.

If you want to just print you know, welcome or something. Instead of putting it in a variable, you can just put it in double quotes and the message will be displayed, but to display the value of a string message We have to use the string variable name. And that's all we have to do we don't have to use to string because it is already a string type variable right and it will display the message 62 or in our previous case like UiPath Okay, next date time. So, date time variable or date time data type is going to store values corresponding to some date time information right. Again in here, we have used a function of predefined function that is available by dotnet called now function. What now function does is it takes out the current date and time from the from the system that the operation is being performed on.

And we get that data right away in this variable date time variable. So, to print that value to see what the current date time is, there could be a use case for us. We simply use date time variable and again Good, none of us change it to string. So if you want to run this, you can see the current date time on which system is running, that's this date and this particular time. Okay, so the next is going to be a boolean data type. So what boolean data type is it's gonna hold either true or false value.

So these are usually used as flag variables, the variables of boolean data type. So what's a flag variable? a flag variable is like, you know, there are, there is a chance that you want to test a condition and if the condition holds true, you want to go in a certain direction in your workflow. And if it is false, you want to go in another direction. A quick example would be let's say if you are accessing a website, and you take some data from an element in on that website and you want to say, if this if this element is equal to welcome, then if the text corresponding to this element is Welcome, that means I am welcomed in this website. And yes, I want to go further.

And if no, if the value is false if it doesn't match with welcome string, then you can say that you know, no, I'm in the correct incorrect I'm on an incorrect website or something like that. So, the true or false condition is usually usually taken care of by the Boolean variables. And what you can see is once when you'll be assigning a value to a variable, right to Boolean variable, once you write true, it appears in blue color, which means it is a predefined term. It's a predefined terminology, you cannot use a variable called true because it's a value that can be stored or space specific to Boolean variables as well. And in our last chapter as well, we went to continue on error property if you remember, we walked through it and we can set true or false condition. So that means continue on error property, we can say is Type, right.

Okay, next is generic data type. So, Jen data type is something that is a data type that is very specific to you to and can store any kind of data in it, such as text, numbers, date, arrays, etc. When we use any operations within our workflow on these generic data type variables UiPath, automatically converts these variables into the required type and performs the computation. So a quick example would be, let's say in this generic value variable, we have given a value of 75. Right? And now, we want to perform a computation that says that you know, I want to print the addition of integer variable and generic variable.

Okay? So although it's a generic variable, you can see See that the value that you get is 137, which is actually the sum of the two numbers. So it was entered number but UiPath automatically did the implicit conscious conversion of data type, from generic to integer, perform the computation and give give us a perfect result. However, that's not always going to be the case. There is a possibility that you know, because it's, it's an automated system, right? This implicit Canvas conversion, so you cannot totally rely on it.

If If you know that you know, the element that we'll be working off working on is going to be stored in data type. Always use that data type and generic data type should be our last resort. Okay, next is the array data type. So, an array is simply a get like type data items allocated continuously in a memory. So what happens is then area can be created in for any data type, first and foremost. And it's going to be under the same name, let's say airy, the name of an array data type is let's say a.

And it has it can hold, let's say any values, but it has to have a finite number, let's say five. So as you know, and this is of integer datatype, the areas of integer data type, and what it's going to have is at a zero location, this zero location is also called index. So it's your location let's we have a number of five and then at a one location, we have a value of three. So what happens is there is a continuous allocation of same or like type of data items, collectively put under a single name. Right. So what happens is in this array variable, we have used, the variable name is area underscore variable, it's of integer type, and we put we started the curly braces and we gave three values.

That means the length of this error error variable is three. The first element of this is 12, second element is 14, third element of this variable is 90, right? That's how the value has been allocated to it. And if you want to print the, if you print want to print the value of the first element, right, so because the index This is called the index part of the array, so an index always starts with zero for an array, so the zero position of this array variable is going to be the numeric 12. Right, if as you can see, we didn't convert it to string yet. So once we print this, this is going to display the first value of that 12.

If you want to print the second value, simply print one and there you go, the 14 which is the second value of this area. So that's how array is stored in the memory location and is retrieved as well through the index. So array in general has like two different parts. One is called the data value, which we already printed, and the index which defines the location where an element within the array would be present. All right. Other than these, we have another data type called list.

Right. So what list is, it's pretty much same as array. The only difference is that area has a fixed length, while length of a list can be increased or decreased by adding or removing elements from it. So in here, I'm going to use Because see, in every case, we're not going to use the default values we cannot give the values right away there is a possibility or there are going to be a lot of use cases where we will be providing or assigning values to a variable while we are going through a program to our workflow. So for that, we always use assign activity. So first and foremost, let's use an assign activity assign activity where does is, this is like the expression to or the value or whatever it is, is what we need to assign to a variable which is put on the left hand side of this activity.

So, in here, we'll use items, which is a list, right? And we're gonna say First, we're going to say we're going to initialize this, this is only specific to the items are the list data types, that you know, we have to mention that it's a new list of string type. Right? And then, let's say we want to so list is also called a collection. Right? It's, it's like these terminologies are used interchangeably.

What we do is we want to add some value to this list or to this collection, then we have an activity called add to collection, we simply put it here, and the collection is going to be items, right because that's the list name that we have. And the item, the item that you want to add to this list is going to be because we already have a string datatype and this is a, this is a list of string data type of multiple strings, right? So what we're going to do is we're going to assign this string variable and we are going to add it to the items list right. So as you can see, that there is some error right? Let me show you what it says first and foremost, because we need to debug these issues as they come right. So it says that we are using, like the value that we are providing as the item is the variable of string type.

But the list is said to be of object type. Instead, you can see the, like the last line in this error that says that it's an object type. So what we're going to do is the type of argument that we're providing has to be a string type. That's it, you see the animal is gone. That means you're like, at least from the compiler standpoint, you're able to add the data correctly to the list. There could be a runtime error, of course, but for now, that's how it is.

And then what we can do is if you want to check how to retrieve data from a list, what we usually do is we go through a loop, but we'll be discussing loops in our next chapter. But what it does is we start a loop where we're gonna see what are different values we can put in or we have in this list. So what are we gonna do is we're gonna we're reading through the whole list and we're printing the values as we encountered them within that list. That's what it is doing. We will be discussing this in our subsequent chapter. It's one of the very important concepts, but we are just starting a loop or a repetitive sequence of actions that we are going to traverse through the list, one by one.

And as soon as as we pick one item, we display it as we pick the next item we display. So that's how it is. And if we run this, you can see that we assigned the only element was what we assigned was the string variable of which has a value UiPath. And it's a we'll do retrieve that element as well. So that's how the list data items are used. to disk, the variables of list data type.

Okay, so this covers the primitive data types. Now, it's going to be variable scope. Okay? So UiPath allows variables to be kept intact, within sequence are a flowchart, as we have seen before. This is because they shouldn't be accessible to the outside activities or for flow, depending on what sort of information they are holding and what visibility you want for a particular data to be. Right.

And the sequence or flowchart in this case defines the scope of visibility of that variable. Right. And each time you create a sequence, a new scope starts. And if a variable is made available to the entire workflow, like pretty much all the variables that we have used in here, they're called global variables because they can be accessed throughout the whole program. Right? Perfect.

So we should always be you know, very cautious of the fact that you know, the scope of the variables should be should depend on what the usability of the particular data element is going to be throughout the whole program. Next, arguments and importing namespaces along with the information and data items being used in a workflow, variable panel, which is this one in UiPath studio also provides a placeholder for arguments. arguments are the data items that hold some value. Right and are passed from one UiPath project to another. So we may have, you know, different other projects then, and we may want to pass on some data to and fro. So, that's how using the arguments we pass on those values.

And this data is stored dynamically in arguments and passed into the other workflows, thereby enhancing the scalability of our programs. So, argument types are pretty much the same as the variable types that we have just discussed like Boolean generic integer strings etc etc. But alongside they have a direction associated with them which defines as to where the data is supposed to you know go or which defines the information stored in them is supposed to be transferred is it going to be you know in or out or something, these are the different directions that are supported within UiPath for arguments. So, in the arguments with indirection are supposed to be used within the current project itself. These are used to receive the value passed on to them from external workflows. Right.

Similarly, for the outwards arguments with this direction are used to pass information from the current workflow to some other workflows for their for the computations Then we have in and out which is which are like those arguments which can be used to either pass information to other workflows as well as receive information from them as well. And for the property direction, publication is not currently used within the UiPath studio. So, you can probably ignore it Okay. Now, the namespaces in UiPath namespaces are logical groups provided by dotnet framework that stores different types of data collectively, right. So, you can see in here as well, once you will selecting this is like, you know, you can import the namespaces and they can be used into the current workflow using this panel and you can select the import option as well to do you know, get all the possible data types that we may use in our current workflow.

For example, like predefined data types, like data table, data column Data View, etc, can be used by importing system dot data dot namespace. Right. But in most cases, when using a particular data type as variable or argument, the underlying namespaces automatically imported by UiPath. Instead of we have, we don't usually have to manually import it. So this feature minimizes our work and escapes the trivial route of learning complex data structures and library packages. So we don't probably have to worry much about this as well.

Once you'll be using that data type. It will be automatically there. Right? All right. This pretty much concludes the data variables, the arguments, the types and how variables are used within a workflow and we also discussed two activities, the messagebox activity and the Assign activity. I also want to touch on another activity called right line activity.

So what happens is messagebox actually stops the execution of a workflow. Let's say if you want to print the value of a variable in between or you want to print a message, the workflow would be stopped unless you bring unless you click on the OK button. But for right line activity, what it does is, if you want to print the value of a variable, let's say you want to print the string variable, you can do that. And it won't stop the execution of the workflow. But what we'll do is in the output panel itself, it will print the value of that particular variable or the message or the whatever we are trying to do. So just to give a quick example on that as well, it ran and it the bot finished the execution, you can check the output panel.

It says that the execution started and UI path which was the value of the string variable and the execution ended as well. Alright

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.