2. What you'll learn in this
session
At the end of this session you will be able to:
• Explainwhatvariablesareandwhattheyareusedfor.
• Createandconfigurevariablesinanautomationproject.
• Explainwhatargumentsareandwhattheyareusedfor.
• Differentiatebetweenvariablesandarguments.
• UsetheInvokeWorkflowFileactivitytochainworkflowexecutionandpassdatathrougharguments.
• Bestpracticeswhileusingvariablesandargumentsandnamingconventions
3. 3
What are variables?
Variables are containers that can hold multiple data entries (values) of the same
data type. For example, EmailAddress can be a variable that holds the value
"rpadeveloper@uipath.com".
The value of a variable can change through:
• External input
• Data Manipulation
• Passing from one activity to other
Why are they important?
Variables help us pass data from one activity to another. Advancing with any
automation process would be hardly possible without using variables
Variables
4. 4
There are three main ways to create variables in UiPath:
1. From the Variables panel
Navigate to the Variables panel, select the ‘Create Variable’ line and type in the name.
Whenever needed, provide its name in the Designer panel or in the desired Properties
field.
2. From Expressions
Variables can be created from expressions directly in an activity input field or the
Expression Editor. Select a part of the expression and press Ctrl+K. The Set Var field is
displayed. Fill in the name and press Enter. Check its type and scope in the Variables
panel.
3. From the Properties panel
In the Properties panel of any activity, select a field that can be edited press Ctrl+K. The
Set Var field is displayed. Fill in the name and press Enter. Check its type and scope in
the Variables panel.
Creating Variables
5. 5
Variables are configured through their properties. You can set them in the
Variables panel. The main properties in UiPath are:
1. Name
Navigate to the Variables panel, select the ‘Create Variable’ line and type in the name.
Whenever needed, provide its name in the Designer panel or in the desired Properties
field.
2. Type
It defines what kind of data can be stored in the variable. In UiPath, the type is declared
when the variable is created, however there are some types that can accommodate
different types of data.
3. Default Value
In general, variables have initial values that change throughout the process. For most
variables, if no initial value is assigned when the variable is declared, there is a default
rule that assigns a value.
Configuring Variables
6. 6
4. Scope
The part of the workflow in which the variable can be used. Some variables can be global
(used throughout the workflow), others local (used inside an activity).
In real automation scenarios, there are many variables in use. Making all of them
unnecessarily global can cause efficiency issues as well as create the conditions for
confusion.
In UiPath, the scope of a variable cannot exceed the workflow in which it was defined.
Since business automation projects rarely consist of single workflows, we need a
different kind of vehicle to pass data between workflows, and this is called an argument.
You will learn more about arguments shortly in the session.
7. 7
What are arguments?
Arguments are very similar to variables:
•They store data dynamically
•They have the same data types
•They support the same methods and properties
The difference is that they pass data between workflows, and they have an additional property for
this – the direction. Arguments have specific directions: In, Out, and In/Out. These tell the Robot
where the information stored in them is supposed to go.
Why are they important?
Arguments are a key component when it comes to building more complex automations, where you
need to store and use data between multiple workflows.
Arguments
8. 8
There are three main ways to create variables in UiPath:
1. From expressions
Directly in an activity input field or the Expression Editor. Select a part of the expression
and press Ctrl+M (for In arguments) or Ctrl+Shift+M (for Out arguments). The Set Arg
field is displayed. Fill in the name and press Enter. The argument is created. Check its
direction and type in the Arguments panel. Arguments created in these ways
automatically receive the type according to the activity.
2. From the Properties panel
In the Properties panel of any activity, right-click a field that can be edited, and select
Create In Argument or Create Out Argument from the context menu. Alternatively, press
Ctrl+M (In) or Ctrl+Shift+M (Out). The Set Arg field is displayed.
Fill in the name and press Enter. The argument is created and visible in the field. Check
its direction and type in the Arguments panel. The argument type is automatically
generated depending on the selected property.
Creating Arguments
9. 9
3. From the Arguments Panel
Navigate to the Arguments panel. Select the Create Argument line, and fill in the name,
direction and type. A new argument is created.
10. 10
What is a workflow?
A workflow represents a small piece of automation that you can take and re-use in your
projects. It is basically your canvas, the place where you design and work with all the
UiPath Studio activities and it defines the flow of your automation. Hence the name,
workflow.
Moving data around within these workflows is carried out through a collaboration
between variables and arguments. As discussed, data present in variables of a particular
scope, when needs to be transferred to another workflow, has to be shifted on to an
argument which in turn carries it to the other workflow, and vice-versa. This procedure of
transferring the data from one workflow to another is called Importing.
When we use “Invoke Workflow” activity in UiPath Studio, it provides a panel where we
can map all our input and output arguments to their relevant variable counterparts in the
current workflow. Make sure to keep the direction of the arguments accurate and as per
need for proper flow of data within these workflows.
Importing Data From One Workflow to
Other
11. 11
In UiPath Studio, namespaces represent containers that store different types of data.
They enable you to easily define the scope of your expressions, variables and
arguments.
For example, if you have the System.Data namespace imported, you can further
use DataTable, DataView, DataColumn, DataRow and other classes that are available in it,
without having to always type System.Data.DataTable and so on.
You can view and manage namespaces from the Data Manager or from
the Imports panel. Note that some namespaces are automatically imported when you
browse for a .Net type variable or argument.
About Imported Namespaces
12. 12
Meaningful names should be assigned to workflow files, activities, arguments, and
variables in order to accurately describe their usage throughout the project.
To improve readability, variable and argument names should also align to a naming
convention:
•Snake case: First1_Name2, first_name2,
•Upper or lower Camel case: FirstName, lastName,
•Pascal case: First1Name2, First1Name,
•Kebab case: First-Name, First-Name1
Argument names should have a prefix stating the argument type, such as:
in_DefaultTimeout, in_FileName, out_TextResult, io_RetryNumber
Naming Conventions