Ui Path
Ui Path
\
Flowchart. The New Diagram window is displayed.
Note: You can also add a Flowchartactivity to the Main panel to create a new flowchart
workflow. (
2. In theName field type a name for the workflow, such as “First Flowehatt;” and }
click Create. The Main panel is updated accordingly.
3. Create two Int32 variables (intRandomNumber, intGuessNumber) and a String one
(
(strMessage).
4. Set the default value of the strMessage variable to “Guess a number from 1 to 999.0"
TheintRandomNumberstores a random — number between 1 and u
——$—$$
‘QUALITY THOUGHT" worwfacebookcom/qthought T wnvarqualnythoughtin
PH NO: 7675827899, 040-48526948 “0 mal: nfo@qualiythoughein n
&QUALITY THOUGHT UiPath Material
999, intGuessNumber stores the user's guess, and strMessage stores the message that is
going to be displayed to prompt the user.
Name | vaitre ype | Scope Detaut
infrdomNumber tea Main ‘eter a VB expression
inGuestumber sms Main reer 0 VB expres
sunvesage sting Main "Guess. a rune from 110 98.
‘Add an Assign activity to the Main panel, and connect it to the Start node.
In the Properties panel, in, the To field add the intRandomNumber variable.
In the Value field, type new Random().Next(1,999),
Note: This field uses the Random()function to generate a random number between I and 999,
8. Add an Input Dialog activity to the Main panel and connect it to the Assign one.
9. Inthe Properties panel, in the Label field, add the strMessage variable.
10. In the Result field, add the intGuessNumber variable. This activity asks and stores the
user's guesses in the intGuessNumber variable.
11. Add a Flow Decision activity and connect it to the Input Dialog. This activity enables
you to tell the user if he correctly guessed the number or not.
12.In__ the Properties panel, the Condition field, type intGuessNumber =
intRandomNumber. This enables you to verify if the number added by the user is the
same as the randomly-generated one.
13. Add a Message Box activity and connect it to the True branch of the Flow Decision.
14. In the Properties panel, in the Text field, type "Congratulation! You guessed correctly!
‘The number was " + intRandomNumber.ToString + ".”. This is the message that is going
to be displayed if the user correctly guessed the number.
15. Add a new Flow Decision activity 2nd connect it to the Falsebranch of the previously i
added Flow Decision.
46.In the Properties panel, in the Condition field, type intGuessNumber >
intRandomNumber. This activity enables you to check if the number the user added is
bigger than the randomly-generated one.
17.In the DisplayName field, type Comparison. This enables you to easily to tell the
difference between the two Flow Decisionsused.
18, Add an Assign activity and connect it to the True branch of the Comparison activity.
19.In the To field, type the strMessage variable, and in the Value field, type a message
indicating that the guess was too high, such as "Too big. Try again.”
20, Select the Assign activity and press Ctrl+C. The entire activity and its properties are
copied to the Clipboard.
21. Press Ctr+V. A duplicate of the previous Assign activity is displayed.
22. Connect it to the False branch of the Comparison activity and, in the Properties panel,
inthe Value field, type “Too small. Try again.”.
ed
(QUALITY THOUGHT. + wwnwfacebook.com/qthought + www.qualitythoughtin
PH NO: 7675827899, 040-48526948 at Email ld: info@qualitythoughtinQUALITY THOUGHT UiPath Material
23.Connect the Assign activities created at steps 18-22 to the Input Dialog. A loop is,
created, asking the user to type a smaller or bigger number, until he guesses correctly.
‘The final workflow should look as in the screenshot below:
a
e
+7 tone! ~ oO
_ : }
State Machines
A state machine is a type af workflow that uses a finite number of states in its execution. It
can go into a state when it is triggered by an activity, and it exits that state when another
activity is triggered.
Another irmportant aspect of state machines are transitions, as they also enable you to add
conditions based on which to jump from one state to another, These are represented by
arrows or branches between states.
‘There are two activities that are specific to state machines, namely State and Final State,
and they are found under Workflow > State Machine.
Note: You can only create one initial state, yet it is possible to have more than one Final
State.
‘The State activity contains three sections, Entry, Exit and Transition(s), while the Final
State only contains one section, Entry. Both of titese activities can be expanded by double-
clicking them, to view more information and edit them.
QUALITY THOUGHT = wwwfacebook.com/qthought = wwwaqualityehoughtin,
PH NO: 7675827899, 040-48526948 42 Email ld: info@qualitythoughtinQUALITY THOUGHT UiPath Material
The Entry and Exit sections enable you to add entry and exit triggers for the selected state,
while the Transition(s) section displays all the transitions linked to the selected state.
{Tin see, cae
P MessageBox a
“Congatulations You guessed correct! The number w
1 Guess No
© Enty
) ImputDiatog a
“Guess the Number
“Add a number between ¥ ans 106
% Transiton(s)
Ty Smaller —> Destination: Try Smale M559
Correct Guess —» Destination: Finalstate
Ty Higher “> Destination: Try Higher Misg
SS
(QUALITY THOUGHT: = wwwéacebook.com/qthought = www.qualitythoughtin
PH NO: 7675827899, 040-48526948 a Email ld: info@qualitythoughtinQUALITY THOUGHT UiPath Material
‘Transitions are expanded when you double-click them, just like the State activity. They
contain three sections, Trigger, Condition and Action, that enable you to add a trigger for
the next state, or add a condition under which an activity or sequence is to be executed.
‘Sty Sater
Sure: Guess Wumoee
Thggee
“Ty Smaies a
Conssiticn
itn infandornNumk
action
1 MessageBox a
our guess 100 big. Try a sinaier value
>» Destination: Guess Number
‘Add shores goer transition
Example of How to Use a State Machine
‘To exemplify how to use a state machine, we are going to build the guessing game we did in
the previous chapter, only we will try to guess a number between 1 and 100.
1, Create a blank workflow and, on the Design tab, in the Filegroup, select New > State
Machine. The New Diagramwindow is displayed.
Note: You can also add a State Machineactivity to the Main panel to create a new state
machine workflow.
OOO ee’
‘QUALITY THOUGHT = wwwfacebook.com/qthought + wwwqualitythoughtin
PH NO: 7675827899, 040-48526948, 44 Email ld: info@qualitythought inQUALITY THOUGHT UiPath Material
2. Create two integer variables, intGuess and intRandomNumber. The first variables stores
your guess, while the second stores the random number.
3. ‘Add a State activity to the Main pane and connect it to the Start node. This is the intial
state, and it is used to generate the random number.
4. Double-click the activity. This State activity is displayed explanded in the Main panel.
5. In the Properties panel, in the DisplayName field, type Initializing Random Number.
This enables you to easily tell states apart.
6. Inthe Entry section, add an Assign activity.
7. Inthe To field, add the intRandomNumber variable.
8. In. the Value field, type new Random().Next(1,100). This expression generates a
random number.
9, Return to the main workflow view and add a new State activity.
10. Connect it to the previously added activity.
11. Double-click the last added State activity. This activity is displayed expanded in
the Main panel.
12.In the Properties panel, in the DisplayName field, type Guess Number. This state is
used to prompt the user to guess a number.
13. In the Entry section, add an Input Dialog activity.
14.Select theInput Dialog, and inthe Properties panel, add an
appropriate Label and Title to prompt the user to guess a number between 1 and 100.
15.In the Result field, add the intGuess variabie. This variable stores the user's guess.
16, Return (0 the main workflow view and create a transition that points from the Guess
Number state to itself.
17. Double-click the transition. The transition is displayed expanded in the Main panel
18.In the Properties panel, in the DisplayName field, type Try Smaller. This message is
displayed on the arrow, enabling you to ran through your workflow easier
19. n the Condition section, type iniGuess > intRandoraNumber. This verities if the user's
guess is bigger than the random number.
20. In the Action section, add a Message Box activity.
21.In the Text field, type something similar to "Your guess is too big. Try a smaller
number.” This message is displayed when the user’s guess is bigger than the random
number.
22,Return to the main workflow view and create a new transition that points from
the Guess Number state to itself.
23, Double-click the transition. The transition is displayed expanded in the Main panel
24.10 the Properties panel, in the DisplayName field, type "Try Bigger.”. This message is
displayed on the arrow, enabling you ts tun through your workflow easier.
25.In the Condition section, type intGuess < intRandomNumber. This verifies if the guess
is smaller than the random number.
26.In the Action section, add a Message Box activity.
27.In the Text field, type something similar to "Your guess is too small. Txy a bigger
number." This message is displayed when the users guess is smaller than the random.
number.
28, Return to main workflow view and add a Final State activity to the Main panel.
29. Connect a transition from the Guess Number activity to the Final State.
30. In the Properties panel, in the DisplayName field, type Correct Guess.
SS
(QUALITY THOUGHT = www facebookccom/qthoughe + wwwwaqualityhoughtin
PH NO: 7675827899, 040-48526948 5 Email ld: info@qualitythoughtinQUALITY THOUGHT UiPath Material
31, In the Condition field, type intGuess = intRandomNumber. This
which this workflow steps to the final state and end.
32, Double-click the Final State activity. It is displayed expanded in the Main panei.
33. nn the Entry section, add a Message Box activity.
34,In the Text field, type something similar to "Congratulations. You guessed correctly!
‘The number was * + intRandomNumber.ToString + ".". This is the final message that is
to be displayed, when the user correctly guesses the number.
the condition on
The final workflow should look as in the following screenshot.
Gi :
fis. Sate Madioe
@ Sutocire
‘aoa 8 Cote
©
FE sing anton tn
oO
¥ " Bl Foastate
Giese
° ‘ a :
| se
“Vattbies Aegurens imports @Pom HE
35, Press F5. The workflow is executed correctly.
A
QUALITY THOUGHT * _-www.acebook.com/qthought *
‘www.qualitythoughtin
PH NO: 7675827899, 040-48526948 46 Email Id: info@qualitythoughtinQUALITY THOUGHT UiPath Material
lessageBox x
| Congratulations. You guessed correctly! The number was 8.
3.Yariables
Managing Variables
Managing Variables
In UtPath Studio, variables are used to store multiples type of data. Another key aspect of
variables is that their value can change so that you can, for example, control how many
times the body of a loop is executed
‘The data stored within a variable is called a value, and it can be of multiple types. In UiPath,
we support a large amount of types, ranging from generic value, texi, number, data table,
time and date, to UiElements.
Creating Variables
Note: Variables cannot be created if theMain panel does not contain at least one activity.
From the Design ribbon:
1. On the Design ribbon tab, in the Variables group, sclect Create Variable > [Type of
variable}. The Create Variablewindow is displayed.
Create Number Variable
iris [variabter
Defautt Valve "0
Global Variable E71.
: [Ceancer J
ce
QUALITY THOUGHT * www.facebook.com/qthought 7 www qualitythoughtin
PH NO: 7675827899, 040-48526948 47 Email Id: info@qualitythoughtinQUALITY THOUGHT UiPath Material
2
I in the required fields and click OK. The variable is created and you can view and edit
it in the Variables panel
From the context menu or with a keyboard shortcut:
UiPath Dialog Activities InputDialog
EID | searen [
3 Common
i]
Clear |
DisplayName ‘nputciatog
i Input |
IsPassword Qo
Label Type 8 number.
Options
Tite Secona Numver [= |
© Mise
Private
© output
real Variable, cr
F reperties FE Outine 4 Output
1. In the Properties panel of any activity, right-click a field that can be edited, and
select Create Variable from the context menu, or press Ctrl+K. A Set Name field is
displayed.
2. Fill in the name and press Enter. The variable is created and you can view and edit it in
the Variables pancl. The scope of activities created like this always belongs to the
smallest container itis part of.
Note: When creating variables like this, the type is automatically generated, depending on
the selected property,
SS
‘QUALITY THOUGHT + www.acebook.com/qthought + www.qualitythoughtin
48
PH No: 7675827899, 040-48526948 Email Id: info@qualitythoughtinQUALITY THOUGHT UiPath Material
From the Variables panel:
Name Vaiabletype Scope eta
inser in aia ite 018 eesion
ineconumber In Wain
te
<> Arguments npr Wem RE
1. Inthe Main panel, click Variables. The Variables panel is displayed.
2. Click the Create Variable line. 4 new variable with the default values in displayed.
Note: By default, all new variables are of String type if you create them from
theVariables panel
Removing Variables
+ Inthe Variable panel, right-click a variable and select the Delete option.
+ Inthe Variable panel, select a variable and press the Delete key.
Note: If you want to undo this action, press Ctrl+Z,
You can also remove all the variables that are not used in your currently opened workflow:
1. On the Design ribbon tab, in the Variables group, select Manage Variables > Remove
Unreferenced. Note that the Variables panel only contains the variables used in your
‘workflow.
Browsing for .Net Variable Types
To search for types of variables that are not displayed by default in the Variable Type list,
do the following:
1. In the Variable panel, from the Variable Type drop-down list, select Browse for
‘Types. The Browse and Select a Net Type window is displayed.
re
‘QUALITY THOUGHT = wwwfacebook.com/qthought * woww.qualitytnoughtin
PH NO: 7675827899, 040-48526948 49 Email Id: info@qualitythoughtinQUALITY THOUGHT UiPath Material
Browse and Select a Net Type
| Twentame: [cel _ | :
[4