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
€93.20
List Price:  €130.49
You save:  €37.28
£79.91
List Price:  £111.88
You save:  £31.96
CA$136.56
List Price:  CA$191.19
You save:  CA$54.63
A$153.05
List Price:  A$214.27
You save:  A$61.22
S$136.08
List Price:  S$190.51
You save:  S$54.43
HK$782.75
List Price:  HK$1,095.88
You save:  HK$313.13
CHF 91.21
List Price:  CHF 127.70
You save:  CHF 36.49
NOK kr1,100.23
List Price:  NOK kr1,540.37
You save:  NOK kr440.13
DKK kr695.05
List Price:  DKK kr973.10
You save:  DKK kr278.04
NZ$168.07
List Price:  NZ$235.31
You save:  NZ$67.23
د.إ367.25
List Price:  د.إ514.16
You save:  د.إ146.91
৳10,970.75
List Price:  ৳15,359.49
You save:  ৳4,388.74
₹8,335.10
List Price:  ₹11,669.48
You save:  ₹3,334.37
RM476.90
List Price:  RM667.68
You save:  RM190.78
₦130,608.93
List Price:  ₦182,857.73
You save:  ₦52,248.80
₨27,840.21
List Price:  ₨38,977.41
You save:  ₨11,137.19
฿3,694.31
List Price:  ฿5,172.18
You save:  ฿1,477.87
₺3,253.72
List Price:  ₺4,555.34
You save:  ₺1,301.61
B$515.88
List Price:  B$722.26
You save:  B$206.37
R1,886.05
List Price:  R2,640.54
You save:  R754.49
Лв182.13
List Price:  Лв254.99
You save:  Лв72.85
₩137,567.94
List Price:  ₩192,600.62
You save:  ₩55,032.68
₪380.78
List Price:  ₪533.11
You save:  ₪152.32
₱5,769.12
List Price:  ₱8,077
You save:  ₱2,307.87
¥15,680.08
List Price:  ¥21,952.74
You save:  ¥6,272.66
MX$1,724.22
List Price:  MX$2,413.98
You save:  MX$689.75
QR364.68
List Price:  QR510.56
You save:  QR145.88
P1,379.77
List Price:  P1,931.74
You save:  P551.96
KSh13,498.65
List Price:  KSh18,898.65
You save:  KSh5,400
E£4,789.68
List Price:  E£6,705.74
You save:  E£1,916.06
ብር5,693.24
List Price:  ብር7,970.76
You save:  ብር2,277.52
Kz83,560.30
List Price:  Kz116,987.77
You save:  Kz33,427.46
CLP$94,840.51
List Price:  CLP$132,780.51
You save:  CLP$37,940
CN¥724.59
List Price:  CN¥1,014.46
You save:  CN¥289.86
RD$5,873.12
List Price:  RD$8,222.61
You save:  RD$2,349.48
DA13,427.17
List Price:  DA18,798.58
You save:  DA5,371.40
FJ$225.97
List Price:  FJ$316.37
You save:  FJ$90.39
Q777.73
List Price:  Q1,088.86
You save:  Q311.12
GY$20,914.34
List Price:  GY$29,280.91
You save:  GY$8,366.57
ISK kr13,988.60
List Price:  ISK kr19,584.60
You save:  ISK kr5,596
DH1,011.63
List Price:  DH1,416.33
You save:  DH404.69
L1,776.81
List Price:  L2,487.61
You save:  L710.79
ден5,738.79
List Price:  ден8,034.54
You save:  ден2,295.74
MOP$805.67
List Price:  MOP$1,127.97
You save:  MOP$322.30
N$1,914.68
List Price:  N$2,680.63
You save:  N$765.95
C$3,678.96
List Price:  C$5,150.69
You save:  C$1,471.73
रु13,310.19
List Price:  रु18,634.81
You save:  रु5,324.61
S/372.97
List Price:  S/522.18
You save:  S/149.20
K385.04
List Price:  K539.08
You save:  K154.03
SAR375.02
List Price:  SAR525.04
You save:  SAR150.02
ZK2,631.59
List Price:  ZK3,684.33
You save:  ZK1,052.74
L463.78
List Price:  L649.31
You save:  L185.53
Kč2,343.96
List Price:  Kč3,281.64
You save:  Kč937.68
Ft36,581.40
List Price:  Ft51,215.43
You save:  Ft14,634.02
SEK kr1,089.92
List Price:  SEK kr1,525.94
You save:  SEK kr436.01
ARS$87,365.86
List Price:  ARS$122,315.70
You save:  ARS$34,949.84
Bs692.26
List Price:  Bs969.20
You save:  Bs276.93
COP$394,057.74
List Price:  COP$551,696.60
You save:  COP$157,638.86
₡50,249.28
List Price:  ₡70,351
You save:  ₡20,101.72
L2,468.18
List Price:  L3,455.56
You save:  L987.37
₲742,598.03
List Price:  ₲1,039,666.95
You save:  ₲297,068.91
$U3,834.62
List Price:  $U5,368.62
You save:  $U1,534
zł402.81
List Price:  zł563.95
You save:  zł161.14
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.