0% found this document useful (0 votes)
6 views

Lesson 3 Variables and Arguments

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Lesson 3 Variables and Arguments

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 44

RPA Design

and Development
V3.0

STUDENT MANUAL – Lesson 3


Slide 1

RPA Design and


Development
V3.0

Welcome to ‘RPA Design and Development Course’.

1|Page
Slide 2

Lesson 3
Variables and Arguments

The third lesson of this course is Variables and Arguments.

2|Page
Slide 3

Agenda

01 Variables and their Types 06 Argument Directions

02 Variables Panel
07 Arguments vs. Variables

03 Scope of a Variable

04 Arguments

05 Arguments Panel

The agenda of this lesson is:


• Variables and their Types
• Variables Panel
• Scope of a Variable
• Arguments
• Arguments Panel
• Argument Directions
• Arguments vs. Variables

3|Page
Slide 4

Learning Objectives

Define variables and explain their types

Explain variables panel

Explain the scope of variables

Explain arguments

Explain arguments panel

Describe and use argument directions

Compare arguments and variables

By the end of this lesson, you will be able to:


• Define variables and explain their types
• Explain variables panel
• Explain the scope of variables
• Explain arguments
• Explain arguments panel
• Describe and use argument directions
• Compare arguments and variables

4|Page
Slide 5

Variables and their Types


• Introduction to variables
• Properties of variables
• Best practices for naming variables
• Types of variables in UiPath

This section introduces variables and their types in UiPath.

5|Page
Slide 6

Introduction to Variables

Variables are containers that are used to store multiple types of data. A variable:

• makes it easier to label and store data which can later be used
throughout the automation process

• has an initial value which may change during the program


through an external input, data manipulation or passing from
one activity to another

• is like a box that stores data


Example: A box (variable) named Counter that tracks the
number of times users clicked on an item

Variables are containers that are used to store multiple types of data. Using
variables makes it easier to label and store data which can later be used throughout
the automation process.

A variable has an initial value that may change during the program. The value of a
variable can change through an external input, data manipulation, or passing from
one activity to another. A collection variable contains multiple data entries (of the
same type).

It is useful to think of a variable like a box that stores data.


For example:
• A box (variable) named Counter that tracks the number of times users clicked on
an item.

6|Page
Slide 7

Properties of Variables

Users can configure variables through their properties:

01 02
Name Type
Name of the variable Kind of data that the
variable is intended to
store

03 04
Value Scope
Data that a variable Designates parts of a
holds (may change program that can use a
during the process) variable (local, global)

The user can configure a variable through its properties. The variables have the
following properties:

• Name: The name of a variable is its unique ID. It represents the "title" of the
information that is being stored by the variable. A variable should be named to
represent all possible values that it might contain. The name is essential in
programming, because the user "accesses" the variable through the name. Every
variable must have a unique name and it should be descriptive enough so that
other users can easily read it and save time.

• Type: Type defines the kind of data that the variable is intended to store. The
type is declared when the variable is created. There are some specific types that
are more generic and can accommodate different types of data. The most
common (universal) types of a variable are: text, number, array, date/time,
Boolean, and data tables.

• Value: Value is the data that a variable holds. The value of a variable may
change during the process. Suppose a variable named ‘tasks’ is assigned a
value ’12’ initially. At another point, ‘tasks’ may be assigned the value ’27’. If no
initial value is assigned at the creation of the variable, a default rule assigns a
value to the variable.

• Scope: Scope defines from where the variable can be accessed in the workflow.
The variables can be global or local. If the user defines a variable with local
scope, then outside processes cannot access it. There are always several
variables in use, so the users should avoid making multiple variables
unnecessarily global and not a part of the program, as it may cause efficiency
issues.

7|Page
Slide 8

Best practices for naming variables

A variable’s name should be meaningful and hint towards the information it stores. While naming any
variable, the user should:

Use clear & meaningful names Use Camel case

Assign names in a consistent manner Keep the variable names descriptive yet
short

The name of a variable should be meaningful and describe the information it stores.
This makes it easier to understand the purpose of the variable and to maintain it.

For this, the users must follow the best practices for naming a variable and should:
• Use clear & meaningful names (the name of the variable should accurately
describe its content)
• Assign names in a consistent manner
• Adhere to using upper Camel Case, e.g. FirstName, LastName
• Keep variable names descriptive yet short

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/st-nmg-001

8|Page
Slide 9

Types of Variables

Different types of variables in UiPath Studio are:

String DataTable
01 05

02
Boolean QueueItem
02 06

Number Array
03 07

Date and Time


04

The type of a variable defines the type of data that can be stored inside the variable.
The different types of variables available in UiPath Studio are:

• String (Text) variable


• Boolean (True or False) variable
• Number variable
• Date and Time variable
• Data Table variable
• QueueItem variable
• Array variable

These are discussed in detail in the subsequent slides. In addition to these, for
complex situations, the users can declare data types of .Net type variables which
are also available in UiPath Studio.

Also, in addition to these, there are two collection variables: Lists and Dictionaries
which will be discussed in Lesson 6 of this course.

9|Page
Slide 10

1. String Variables

Definition Usage Example

String variables help To store text and reuse • Company Name in


store any sequence of it in the code for Invoice
text specific actions • Variable name
can be
CompName
with value “XYZ
Corp”.

String (Text) Variables are variables in which the users can store only strings, i.e., a
sequence of text. These variables can store information like usernames, employee
names, etc. When assigning values to a string variable, the values are typed in
double quotes.

String variables are used to store text and reuse it in the code for specific actions. It
can be the name of a person, the address of a person, etc.

Example:
Consider that an invoice is being generated. There are various fields mentioned in
the invoice. These fields are represented using different variables. Here, the name of
the company is an example of a string variable as it takes a string value. (Company
Name could be XYZ Corp.)
• Variable name can be CompName with value “XYZ Corp”.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/text-variables for


example of using a string variable.

10 | P a g e
Slide 11

2. Boolean Variables

Definition Usage Example

Boolean variables hold Used with control • Is the item available


only two values: “True” statements to help in the invoice?
or “False” determine the flow of a • TRUE when the
program item is available
• FALSE when the
item is
unavailable

A Boolean variable (also known as true-false variable) has only two possible values:
“True” or “False”.
The Boolean variable is primarily associated with conditional statements, which allow
different actions by changing control flow depending on whether a programmer-
specified Boolean condition evaluates to true or false. Thus, Boolean variable is
commonly used with control statements to determine the flow of a program as they
enable the user to make decisions. A variable holds TRUE when a condition is met,
FALSE when a condition is not met.

Example:
Holds TRUE when the item in the invoice is available, holds FALSE when the item is
unavailable.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/true-or-false-


variables for example of using a Boolean variable.

11 | P a g e
Slide 12

3. Number Variables

Definition Usage Example

Number variables store To execute equations • Item Quantity


numeric values or perform • Variable name
comparisons, pass can be
important data, etc. ItemQuant with
value 50

Number variables (also known as integer) are the variables in which the user can
store numeric values. They are used to execute equations or perform comparisons,
pass important data, etc. Number variables specify values such as age of a person:
(eg: 34). Number variables are also known as Integer or Int32.

Example:
Item Quantity.
• Variable name can be ItemQuant with value 50.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/number-variables


for example of using a Number variable.

12 | P a g e
Slide 13

4. Date and Time Variables

Definition Usage Example

Date and time variables Used to calculate the • Invoice Date


store information about number of days • Variable name
any date and time between two dates, can be InvDate
store current date with value
details, etc. 01/01/2020

The date and time variable is a type of variable that enables you to store information
about any date and time such as a variable Today holds today’s date.

The main usage of the Date & Time variable is to store a specific date and time
inside or to perform other operations with them. (Ex. Calculate how many days are
left until the end of the month). They may be used to append dates to time-sensitive
invoices or documents.

Example:
Invoice Date
• Variable name can be InvDate with value 01/01/2020.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/date-and-time-


variables for example of using Date & time variable.

13 | P a g e
Slide 14

5. DataTable Variables

Definition Usage Example

DataTable variables Used to migrate data • List of all items in the


store tabular data in from a database to invoice
rows & columns and another, extract • Variable name
may hold large pieces information from a can be
of data & act as a website and store it dt_InvItem with
database locally in a spreadsheet values Item1,
Item2, Item3,….

DataTable variables can store tabular data in rows and columns and may hold a
large amount of information and act as a database. In UiPath Studio, DataTable
variables can be found in the Browse and Select a .Net Type window. You can
access this window by clicking the Browser for Types option from the drop-down
menu in the Variable Type column of the Variables panel.

The practical usage of data tables is to store big pieces of information and do certain
operations on them, such as filtering, searching, copying, etc. They are often used to
migrate data from a database to another, extract information from a website and
store it locally in a spreadsheet.

Example:
List of all items in the invoice with the quantity of each
• Variable name can be dt_InvItem with values Item1, Item2, Item3,….

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/data-table-


variables for example of using the DataTable variable.

14 | P a g e
Slide 15

6. QueueItem Variables

Definition Usage Example

A variable particular to Used to input extracted • A particular invoice


UiPath, the QueueItem items in other in the queue of
variable stores an item processes invoices
extracted from a queue
(container of items)

The QueueItem variable stores an item that has been extracted from a container of
items, a queue. Through this extraction, the user can further use the queue items in
other processes. It is a proprietary variable of UiPath.

Example (use of a QueueItem variable):


An employee of a bank wants to process the data of 50 clients using a third-party
financial application. Assume that the third-party application is installed on a different
machine.

Let’s call the employee’s machine as the First machine and the machine where the
third-party application is installed as the Second machine.

The employee creates two automation projects. The first automation project is
created on the First machine to upload the client data to Orchestrator. The second
automation project is created on the Second machine to retrieve the client data from
Orchestrator for processing.

1) First Automation Project


In Orchestrator, the employee creates a queue called CustomerQueue to
store the client data. Afterward, an automation project is created by the
employee on the First machine. Upon execution, this automation project
uploads all the 50 transaction items to CustomerQueue for further processing.

2) Second Automation Project


The employee creates another automation project on the Second machine. It
retrieves the data from CustomerQueue and processes it in the third-party
application. To do this, a Get Transaction Item activity is used in this
automation project. In the TransactionItem property of this activity, a

15 | P a g e
QueueItem variable is created called TransItem. Upon execution, the
automation project retrieves each transaction item from CustomerQueue and
stores it in TransItem. And then the stored value of TransItem is further
processed in the third-party application.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/queueitem-


variables for example of using QueueItem variable.

16 | P a g e
Slide 16

7. Array Variables

Definition Usage Example

An Array variable is a Used to organize data • An array of names of


collection that stores so that a related set of two items
multiple elements of the values can be easily • Variable name
same data type sorted or searched can be
ArrCompName
with value
{“ABC”, “XYZ”}

An array is a data structure that contains a group of elements of the same data type,
such as an integer or string. So, an Array variable enables users to store multiple
values of the same data type.

An array is a type of collection variable used to store multiple entries. The size of an
array is defined when it is created, and it is not dynamic.

A search engine may use an array to store Web pages found in a search performed
by the user.
When displaying the results, the program will output one element of the array at a
time. This may be done for a specified number of values or until all the values stored
in the array have been displayed.
While the program could create a new variable for each result found, storing the
results in an array is a more efficient way to manage memory.

Example:
• Variable name can be ArrCompName which is an array of two strings: Company
Name 1 and Company Name 2
(Based on previous examples of String Variables, the value of this array could be
{“ABC”, “XYZ”}).

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/array-variables


for example of using an array variable.

17 | P a g e
Slide 17

Array vs. String

Array String

It is a sequential collection of elements of It is a sequence of single characters represented


similar data types. as a single data type.
Its elements are stored contiguously in It can be stored in any manner in memory
increasing memory locations. locations.

It is a special variable that can hold more than


It can hold only character data.
one value at a time.

Its length is predefined. Its size is not predefined.

Array:
• It is a fixed-size sequenced collection of elements of the same base types that
share a single name and can be used to represent a list of names or numbers.
• Its elements are stored contiguously in increasing memory locations.
• It is a special variable that can hold more than one value at a time.
• Its length is predefined.

A string is similar to an array with a few exceptions.

String:
• It is a sequence of single characters represented as a single data type.
• It can be stored in any manner in memory locations.
• It can hold only character data.
• Its size is not predefined.

18 | P a g e
Slide 18

Variables Panel
• Introduction to Variables Panel
• Managing variables

This section gives an overview of the Variables panel and how to manage variables.

19 | P a g e
Slide 19

Introduction to Variables Panel

Enables the users to create variables and modify them.

Studio has a Variables Panel that enables the users to create variables and modify
them.

The panel is located at the bottom right side of the Activities panel and it is hidden by
default. When clicked, the panel opens and displays the existing variables in the
project and allows the user to modify them. Whenever a user changes the name of a
variable in this panel, it automatically gets updated at all occurrences in the current
file.

The Variables Panel consists of fields through which the users can define the
different properties of a variable. For both existing and new variables, it has the
following fields:

• Name: The user defines a variable by giving it a name. It is the title of the data. If
the user renames a variable in the Variables Panel, it will be renamed in all
instances where it is used. This is useful in complex workflows. If the user does
not add a name to a variable, it is automatically generated.

• Variable Type: The user specifies the data type that the variable will store. The
data type for the variables is chosen from the drop-down list. It can be String,
Array, number (integer), etc. Also, the user can change the variable type by
clicking ‘Browse for Types’ and then choosing from the available list.

• Scope: The user specifies the region in which a variable is visible. When the user
defines any variable scope in the container, then it is available only in those
containers where you define it. When the user defines a variable scope in the
main class, then it is available in all containers.

20 | P a g e
• Default: The user specifies the initial value of the variable in the ‘Default’ field. If
this field is empty, the variable is initialized with the default value of its type. For
example, for an Int32, the default value is 0.

The Variables panel also allows the users to copy variables from one workflow to
another and add/edit comments to a variable.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/the-variables-


panel

21 | P a g e
Slide 20

Managing Variables

In Studio, a user can create variables from the Variables Panel by clicking ‘Create Variable’.

Step 01 Step 02 Step 03


Define a name Choose type from Choose scope
drop-down list

Step 04
Specify a default
value, if required

In order to manage the variables in UiPath Studio, the users need to perform several
actions on them. These are:
• Creating variables
• Initializing variables
• Removing variables

• Creating Variables:
There are 3 ways to create variables in UiPath:
• From the Variables panel – Open the Variables panel, select ‘Create
Variable’, and fill in the fields as needed. (The variable is created, and its
default type is String.)
• From the Designer panel – Drag an activity from the Activities panel into
the Designer panel (Drag an activity with a variable field visible (i.e.
‘Assign’)) and press Ctrl+K. Name it and then check its properties in the
Variables panel. (The variable is created, and its type is according to the
activity.)
• From the Properties panel – In the Properties panel of the activity, place
the cursor in the field in which the variable is needed (i.e. Output) and
press Ctrl+K. Name it and then check its properties in the Variables panel.
(The variable is created, and its type is according to the selected property.)

The user can create a variable only when the Designer panel contains at least one
activity.

2. Initializing variables

22 | P a g e
While creating a variable, its properties need to be initialized. This is known as the
initialization of a variable. The user can create a variable by following the steps
mentioned earlier and initialize it as follows:
1. Define a name for the variable (one that defines the variable and will be
easy to remember later in the automation workflow)
2. Choose the type of variable from the drop-down list. This list displays the
types that a user has mostly used. In case a different type is needed, the user
can click on “Browse for types…” (The last option in the drop-down list) which
opens a separate screen of the project window, Browse and Select a .Net
Type, where the user can use keywords to search for the desired type. Click
on it to add the type.
3. Choose the scope (available only in the sub-process or for the entire
workflow)
4. Now enter a default value, if required

When a string variable is assigned a value that contains quotations, users need to
use each quotation character twice; otherwise, it will be considered as a string
delimiter.

Collection variables: The process of creating collection variables is similar to the


process of creating simple variables (numbers, characters, strings, etc.). However,
for initializing collection variables, the user needs to specify the type of collection
variable (it may be Strings, Integers, etc. and then, it will create an Array of strings, a
List of Integers, and so on respectively).

3. Removing variables
A user can follow either of the following steps to remove a variable:
• Open the Variables panel, right-click a variable, and select
the Delete option.
• Open the Variables panel, select a variable and press the Delete key.

To remove all the unused variables available in the Variables panel, click Remove
Unused Variables on the Design ribbon tab. This removes the variables not used in
the currently opened project and also the ones that are unused but mentioned in
annotations.

23 | P a g e
Slide 21

Classroom Exercise

Demonstrate ‘How to create variables’ using:


• Variables panel
• Designer panel
• Properties panel

Demonstrate how to create variables using Variables, Designer, and Properties


panel.

Manage variables through the Variables panel:

• In the Designer panel, click the Variables tab. The variables panel is empty.
• Drag and drop Sequence activity in the designer panel.
• In the Variables panel, click Create variable and enter a variable name, say
Username.
• Right click on this variable and select Delete to delete this variable.

Create variables in Activities within the Designer panel:

• Drag and drop two Message Box activities within the Sequence activity.
• Right click in the text area of the first Message Box activity and select Create
Variable from the context menu.
• Enter variable name, say intMarks, after Set Var.
• In the Variables panel, change its Variable type to Int32 for integer and enter 60 as
its default value.

Manage variables through the Properties panel:

• Click the second Message Box activity.


• Right click its Text property from the Properties panel
• Select Create Variable from the context menu.
• Enter variable name, say Name, after Set Var.
• In the Variables panel, change its Variable type to String and enter “Matthew” as
its default value.

24 | P a g e
• Run the program to get the output of the integer and the string variable.

25 | P a g e
Slide 22

Scope of a Variable
• Introduction to the Scope of a Variable

This section gives an overview of the scope of a variable.

26 | P a g e
Slide 23

Introduction to the Scope of a Variable

The scope determines the containers in which the variable is available.

The scope is chosen from list of


01 sequences in Scope drop-down field
while creating a variable. The variable
is available in the selected container.

A variable declared for


a parent activity is
03 02 A variable declared in
any specific activity is
available in the entire available only for the
workflow. scope of that activity.

Scope field determines the containers in which the variable is available. When the
variable is created, the user chooses the scope from the Scope drop-down field
where all major sequences & sections of the program are listed. The user chooses
one of these sequences and the variable will then be available in that part of the
workflow. The scope of the variable is limited to the selected container.

If a variable is declared for a parent activity, then the variable is available in the
entire workflow. However, if the variable is declared in any specific activity, then it is
available only for the scope of that activity. The scope of a variable cannot exceed
the workflow in which it was defined.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/workflow-


design#variable-scope

27 | P a g e
Slide 24

Introduction to the Scope of a Variable

The scope determines the containers in which the variable is available.

A variable declared in The scope is chosen A variable declared


any specific activity is from list of sequences for a parent activity is
available only for the in Scope drop-down available in the entire
scope of that activity. field while creating a workflow.
variable. The variable is
available in the selected
container.

Scope field determines the containers in which the variable is available. When the
variable is created, user chooses the scope from the Scope drop-down field where
all major sequences & sections of the program are listed. The user chooses one of
these sequences and the variable will then be available in that part of the workflow.
The scope of the variable is limited to the selected container.

If a variable is declared for a parent activity, then the variable is available in the
entire workflow. However, if the variable is declared in any specific activity, then it is
available only for the scope of that activity. The scope of a variable cannot exceed
the workflow in which it is defined.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/workflow-


design#variable-scope

28 | P a g e
Slide 25

Arguments
• Introduction to Arguments
• Properties of Arguments
• Arguments Panel

This section gives an overview of the scope of a variable.

29 | P a g e
Slide 26

Introduction to Arguments

Arguments are used to pass data from one workflow to another.

Arguments
Store data dynamically

Enable users to reuse workflows

Useful in automation projects with


multiple workflows

Arguments are used to pass data from one workflow to another by storing the data
dynamically.
They are similar to variables as they store data and pass it on. However, the
variables pass data between activities, while arguments pass data between
workflows. So, arguments enable the users to reuse automation workflows. Hence,
they can be accessed outside the workflows in which they are defined and are useful
in automation projects consisting of multiple workflows.

30 | P a g e
Slide 27

Properties of Arguments

Users can configure arguments through their properties:

01 02
Name Direction
Name of the Direction from/to
argument which the data is
passed

03 04
Type Value
Kind of data that the Data that an
argument is intended argument holds
to store

The user can configure an argument through its properties, which are similar to that
of variables (except for one, i.e., argument direction). The arguments have the
following properties:

• Name: This specifies the name of the argument. It represents the "title" of the
information that is being stored by the argument. If the user does not add a name
to an argument, it is automatically generated.

• Direction: As arguments pass data between workflows, the users need to


specify the direction from/to which the data is passed. It can be In, Out, and
In/Out (explained in the next section).

• Argument Type: Type defines the kind of data that the argument is intended to
store. In UiPath Studio, the type is declared when the argument is created. The
types of arguments are: string, number, array, date/time, Boolean, and data
tables.

• Default Value: Value is the data that an argument holds. (Must be provided in
English)

31 | P a g e
Slide 28

Arguments Panel
• Introduction to Arguments Panel
• Managing arguments

This section gives an overview of the Arguments panel and how to manage
arguments.

32 | P a g e
Slide 29

Introduction to Arguments Panel

Enables the users to create arguments and modify them.

Studio has an Arguments Panel that enables the users to create arguments and
modify them. Whenever a user changes the name of an argument in this panel, it
automatically gets updated at all occurrences in the current file.

The panel is located at the bottom right side of the Activities panel and it is hidden by
default. When clicked, the panel opens and displays the existing arguments in the
project and allows the user to modify them.

The Arguments Panel consists of fields through which the users can define the
different properties of an argument. It has the following fields:

• Name
• Direction
• Argument Type
• Default Value

33 | P a g e
Slide 30

Managing Arguments

In Studio, a user can create arguments from the Arguments Panel through the ‘Create Argument’
option.

Step 01 Step 02 Step 03


Define a name Set the direction Specify the data type

Step 04
Specify a default
value

In order to manage the arguments in UiPath, the users may need to perform several
actions on them. These are:
• Creating Arguments
• Removing Arguments

1. Creating Arguments

There are 3 ways to create arguments in Studio:


• From the Arguments panel – In the Designer panel, click Arguments to
display the Arguments Panel. Click Create Argument & name it. (The
argument is created, and its default type is String with ‘In’ direction.)
• From the Designer panel – Drag an activity from Activities panel to
Designer panel and press Ctrl+M. Set Arg field is displayed. Name it and
then check its properties in the Arguments panel. (The argument is created,
and its type is according to the activity.)
• From the Properties panel – In the Properties panel of the activity, choose
the field in which the argument is needed (i.e. Output) and press Ctrl+M.
Name it. (The argument is created, and its type is according to the selected
property. Check its properties in the Arguments panel.)

While creating an argument, its properties need to be initialized. The user can
create an argument by following these steps:
• Define a name for the argument.
• Set the direction of the argument (In, Out, In/Out).
• Choose the type of argument.
• Now choose a default value.

2. Removing Arguments

34 | P a g e
A user can follow either of the following steps to remove an argument:

• Open the Arguments panel, right-click an argument and select


the Delete option.
• Open the Arguments panel, select an argument and press the Delete key.

35 | P a g e
Slide 31

Argument Directions
• Introduction to Argument directions

This section gives an overview of argument directions.

36 | P a g e
Slide 32

Introduction to Argument Directions

Specify the direction from/to which the data is passed.

In
01 • Argument can only be used within a given project

Out
02 • Argument can be used to pass data outside a given project

In/Out
03 • Argument can be used both within and outside a project

Argument direction tells the applications where the information stored in them is
supposed to go, i.e., it specifies the direction from/to which the data is passed.

The directions are:


• In – the argument can only be used within a given project.
• Out – the argument can be used to pass data outside of a given project.
• In/Out – the argument can be used both within and outside of a given project.

Argument names should be prefixed for easy identification of the argument direction,
such as in_FileName, out_TextResult, io_RetryNumber.

To know more, visit: https://docs.uipath.com/studio/v2020.10/docs/st-nmg-002

37 | P a g e
Slide 33

Classroom Exercise

Demonstrate how to create and initialize arguments


through the Arguments panel. Create two workflows:
• The first workflow will add two arguments and pass
the result to the other workflow
• The second workflow will then add the values and
return the result

Demonstrate how to create and initialize arguments through the Arguments panel.

• Go to Arguments panel.
• Click Create Argument and enter two arguments named in_intFirstNumber and
in_intSecondNumber.
• Select a Direction for the arguments. You can choose between four available
options:
o In takes value of an argument inside the workflow
o Out takes value outside the workflow.
o In/Out takes value inside or outside the workflow
• For these two arguments, select Direction as In and Argument type as Int32. Int32
is for integers.
• Create a third argument called out_intSum, select Direction as Out, and Argument
Type as Int32.
• Drag and drop an Assign activity in the Designer panel.
• Enter out_intSum in the first text area and
in_intFirstNumber+in_intSecondNumber in the second text area.
• Right click on the Sequence container and select Extract as Workflow from the
context menu.
• Enter SumTwoNumbers as workflow name and click Create.
• Go to the Main file, and create three variables:
o An integer variable intFirstNumber with Variable type as Int32 and Default value
as 5
o An integer variable intSecondNumber with Variable type as Int32 and Default
value as 10
o An integer variable intResult with Variable type as Int32.
• Click Import Arguments within Invoke workflow, and pass the variables for each
argument value:

38 | P a g e
o intFirstNumber for in_intFirstNumber
o intSecondNumber for in_intSecondNumber
o intResult for out_intSum
• Drag and drop a Message box activity below Invoke workflow and enter intResult
in the text area.
• Run the file to get the output as 15.

39 | P a g e
Slide 34

Arguments vs. Variables


• Comparison

This section gives a comparison between arguments and variables.

40 | P a g e
Slide 35

Arguments vs. Variables

Arguments Variables

Argument stores data and passes it between Variable stores data and passes it between
workflows 01 activities

It can be used across multiple workflows It is limited to the workflow in which it is


(direction to be defined) defined

02 through the Arguments


It is created & modified It is created & modified through the Variables
Panel Panel

It is defined by properties: Name, Direction, It is defined by properties: Name, Type,


Type, Default Value Scope, Default Value
03

Arguments and Variables are quite similar to each other. They both are used to store
information of a particular data type and pass it.

But some of the differences between them are:

• Argument stores data and passes it between workflows. Variable also stores data
but passes it between activities.
• An argument can be used across multiple workflows (direction to be defined) but a
variable is limited to the workflow in which it was defined.
• An argument is created & modified through Arguments Panel whereas a variable
is created & modified through Variables Panel.
• An argument is defined by properties: Name, Direction, Type, Default Value
whereas a variable is defined by Name, Type, Scope, Default Value.

41 | P a g e
Slide 36

Practice Exercise

Build a workflow that swaps two numbers using a third


variable.
• Ask the user to input two numeric values and store
in two variables
• Swap the values of both the variables using a third
variable
• Display initial and swapped values of both the
variables in the Output panel

Build a workflow that swaps two numbers using a third variable.

• Ask user to input two numeric values and store them in two variables.
• Swap values of both the variables with each other using a third variable.
• Display initial and swapped values of both the variables in the Output panel.

Process Overview
• START
• Use Input Method activity to receive two numeric values from the user
• Store the received values in two integer variables called First_Input_Value, and
Second_Input_Value
• Declare a third integer variable called Swapping_Support_Variable
• Use Assign activity to assign value of First_Input_Value to
Swapping_Support_Variable
• Use second Assign activity to assign value of First_Input_Value to
Second_Input_Value
• Use third Assign activity to assign value of Second_Input_Value to
Swapping_Support_Variable
• Use Write Line activity to display initial and final values of First_Input_Value and
Second_Input_Value in the Output panel
• STOP

42 | P a g e
Slide 37

Summary

01 Variable and its Types

02 Variables Panel

03 Scope of a Variable

04 Arguments

05 Arguments Panel

06 Argument Directions

07 Argument vs. Variable

To summarize, this lesson explained:


• Variable and its Types
• Variables Panel
• Scope of a Variable
• Arguments
• Arguments Panel
• Argument Directions
• Argument vs. Variable

43 | P a g e

You might also like