In our previous UIPath Tutorial, we have discussed UIPath components, its features, and how we can install UIPath.
Now in this UIPath tutorial, we will see the below topics.
Tutorial 1: My First Sequence workflow Project – Display welcome message.
Tutorial 2: Accept Input from a user.
Tutorial 3: Use If condition and variables in the process.
Tutorial 4: Variables introduction (String) & Use of Substring function.
Tutorial 5: Variables introduction (Integer)
Tutorial 6: Variables introduction (Boolean)
Tutorial 7: Introduction to flowchart workflow
Tutorial 8: Introduction to State Machine
Tutorial 1:
Display “Hi welcome to my first Project”
Step 1: Create a new blank process
Add Process Name and Description.
Step 2: On Design Tab ->In Main.xaml: Add workflow type
- Sequence Chart-Used for the action which need to perform one after other.
- Flow chart –Used to create complex business process as it allows us to do multiple branching of logical operators.
- State machine
- Global handler
Step 3: On Activity: add message box, click, read excel , send email etc.
Select Sequence -> Select Message Box-> add message “Hi welcome to my first project”
Step 4: Debug-> Run File: see the result.
Tutorial 2:
Display “Hi Noah Welcome to my first Project”
- Continue with the first tutorial: add activity –Input Dialog
-Add Input Label and Dialog Title.
- Create Variable ‘Name’ and Variable Type as String.
- Use that Variable in Message Box, as below
“Hi, “+ Name +” welcome to my first project”
- Input Dialog ->Propertise ->Output->add variable ‘Name’
- Debug->Run File
Tutorial 3:
Variable-Year (e.g. 2021,2022 etc.)
Condition: Check if the year is Leap year or not
If the Year is leap year (Condition is True)-Display Message-“The year is leap year”.
If the Year is not leap year (Condition is False)-Display Message-“The year is leap year”.
Steps 1:
Create New Blank Process.
On Design tab: Click On Main.xaml .
On Activity /tab: Select Sequence Workflow.
Steps 2:
Create Variable ‘Year’ select Variable Type and Default value.
Step 3: Add Input Dialog box ->add Dialog Title as “Enter the year“and Input Label as “Year Value”.
Add If Activity :
Step 4: Add If Condition for leap year
Year Mod 4=0
Step 5: Add message box activity for then and else condition. Add Text as below
Step 6:Debug File->Run File
Enter Year Value as 2020 (Leap Year)
Step 7 :Debug File->Run File
Enter Year Value as 2021(Not Leap Year)
Tutorial 4: Text/String Variable- Substring variable project
- Take User Name as User Input –Input Dialog
- Display the first three letters of the user name in Message Box
- Display User name in message box – Message Box
- “The user name is “ + Username
Steps to follow:
-Create New Processes->On Design tab->On Main.xaml->Add Sequence workflow->add Activity Input Dialog box
-Enter Dialog title and Input Label
-Create two String Variables- UserName and NewName for substring
-Add Assign activity -for display the three letters of the user name
Index-0 and length=3 assign the Index and length value in Substring
NewName = Username.substring(0,3)
-Add Message Box Activity
“The First three letters of Usename is ” +NewName
-Add Message Box Activity
“The Username is ” + UserName
Tutorial 5: Number Variable/Integer Variable/Int32 Variable –Used to store Numeric Information
Display User –John and display total marks
-Create 3 Variable for Subject like MarksInMath, MarksInEng, MarksInSS and TotalMarks
-Create 1 variable for Student Name like StudName
-Take User input for marks obtained in Math and assign the value to Variable –MarksInMath
-Take User input for marks obtained in English and assign the value to Variable – MarksInEng
-Take User input for marks obtained in Social Science and assign the value to Variable – MarksInSS
-Add Total Marks and Assign to New Variable to variable -TotalMarks
TotalMarks= MarksInMath+MarksInEng+MarksInSS
-Display Total Marks in Message Box.
StudName + ” total marks is = ” + TotalMarks.ToString
Note: Add Variable as Output Result for each Input dialog box Properties
Tutorial 6: Boolean Variable – True/False
Variable-Year (e.g. 2021, 2022 etc.) , BooleanVar – Boolean Variable
Condition: Check if the year is Leap year or not
If the Year is leap year (Condition is True)-Display Message-“The year is leap year”.
If the Year is not leap year (Condition is False)-Display Message-“The year is leap year”.
Steps 1:
Create New Blank Process.
On Design tab: Click On Main.xaml .
On Activity /tab: Select Sequence Workflow.
Steps 2:
Create Variable ‘Year’ select Variable Type as Int32 and ‘BooleanVar’ asBoolean variable.
Step 3: Add Input Dialog box ->add Dialog Title as “Enter the year“ and Input Label as “Year Value”
Step 4: Add If Condition for leap year
Year Mod 4=0
Step 5: If the condition is True then:
- Assign Activity -> Add
BooleanVar=True
- Add Message Box Activity and to Display message for e.g “True Year 2020 is leap year”
Add message as below:
BooleanVar.ToString + ” Year ” + Year.ToString + ” is a leap year”
Note: In message box only String values can be display here we have to display Boolean and Integer variable so have to use convert to string function.
Step 6: : If the condition is False then:
Add Message Box Activity and to Display message for e.g “True Year 2021 is not leap year”
Add message as below:
BooleanVar.ToString + ” Year ” + Year.ToString +” is not leap year”
Tutorial 7: Flowchart workflow
Compare two numbers:
- Add flowchart workflow type.
- Create two number variables –RandomNumber, GuessNumber- Number Variables
- Generate random number using the random() function –new random().Next(1,10) and assign to RandomVariable
- Take user Input from number from 1 to 10 and assign it to GuessNumber variable –Input dialog
Note: Add Variable as Output Result for each Input dialog box Properties
5. Condition->Compare RandomNumber,GuessNumber
GuessNumber>=RandomNumber
6. Take Decision according to the condition
If the condition is true (GuessNumber>=Randomnumber) then display a message
-“Your guessed number is equal to or greater than Random Number”.
7. If condition is False (GuessNumber<Randomnumber) then display message
-“Your guessed number is equal to or smaller than Random Number”.
8. And to display e.g. ‘Random Number is 8 and Guess Number is 6’. Add below message in message box.
“Random Number is ” + RandomNumber.ToString + “and Guess Number is ” + GuessNumber.ToString
If a condition is true (GuessNumber>=Randomnumber) then display message
-“Your guessed number is equal to or greater than Random Number”.
And to display e.g ‘Random Number is 8 and Guess Number is 6’. Add below message in the message box.
“Random Number is ” + RandomNumber.ToString + “and Guess Number is ” + GuessNumber.ToString
If condition is False (GuessNumber<Randomnumber) then display message
-“Your guessed number is equal to or smaller than Random Number”.
Debug File->Run File: Enter Guess Number=8
Debug File->Run File: Enter Guess Number=3
State Machine workflow:
A state machine is a type of automation 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.
Two activities – State and Final State .Both of these activities can be expanded by double-clicking them, to view more information and edit them.
State activity: conatins Entry, Exit and Transition. 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.
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.
Final State: It only contains Entry.It specifies the action to occure when the state is transioned to.
Tutorial 08: Guess any number between 1 to 10 and find Guess Number is equal to random number.
For this need to verify the below possible state:
Guess Number >Random Number – Retry
Guess Number <Random Number – Retry
Guess Number =Random Number – Final
Steps:
1. Create a blank Process –state machine workflow demo
2. On design tab-Main.xaml- double click on that and select state machine workflow-double click on it.
3. Select state activity to generate the random number. Double-click the activity. This State activity is displayed expanded in the Designer panel.
4. Create two variable RandomNumber and GuessNumebr.
5. Assign activity in entry
RandomNumber= new Random().Next(1, 10)
6. Add message box activity in Exit criteria “Random number is generated”
7. Return to main state machine workflow and add another state activity, to enter Guess Number. Add Input dialog box add Dialog Title and Input label and store variable as output result of Input Dialog box properties.
8. Return to the main project view and create a transition that points from the Guess Number state to itself.(Display Name ->Trysmaller).
Add condition Guessnumber > RandomNumber
Add message box in Action “”Guess Number is greater than Random Number try for smaller number””.
- Return to Main project view and create a one more transition that points from the Guess Number state to itself.(Display Name ->Trygreater).
Add condition Guessnumber <RandomNumber
Add message box in Action “”Guess Number is smaller than Random Number try for greater number””.
- Return to Main project view and add Final State (Display Name->Correct Number).
In transition add condition RandomNumber=GuessNumber.
- Return to Main project view and connect a transition from the Guess Number activity to the Final State.
Add message box and display message “Congratulation you guessed the correct number”.
Add one more message box to display random number “The Random Number is ” + RandomNumber.ToString”.
- The Final Project will look as following screenshot.
- 13. Run File.