Build Simple message Box in UiPath

We can achieve any automation using UiPath RPA, for creating a Message box we need to start the process either with flowchart or with try catch in UiPath.

Search for Message Box in the search box, I would recommend to search every element on the search box rather than going through the modules, as the version changes the elements under the modules also changes, so it is always better and faster to search the element in the search box.

You Drag and drop the Message box after the Flowchart and connect them using portals, we have to fill all the details, otherwise we will see a blue icon on the header of the element.

You need fill details on the properties tab: Button to display, Content, Title
messagebox-uipath-rpa
Press F5 or Click Run icon, you may see output of a message box like below. messagebox-output-uipath-rpa

Variable in UiPath RPA

Variables are nothing but the bucket(container) for values, Variables are important in any program language or in any automation tools. without variables it becomes difficult to handle the value sin the tools.

We can create variable in many ways in UiPath, We will see few ways to create them. Variables help the values to pass between different modules.

Creating variables from the Menu Ribbon :

Navigate to Design tab and variables section; Click on the Create Icon tab, Now Uipath displays few options to create variables of specific types. Those types are : Generic value, Text, Number, Date and Time, True or False, Table

menu-ribbon-variable-uipath-rpa
Once you have selected the type of variable you want to create, UiPath pops the variable creation wizard.
variable-creator-uipath-rpa
In above wizard, you can change the value of the variable name, as well as the variable values. For Text variable you have to give the value inside the " (Double Quotes).

Also you can set/change the scope of the variables in the variable creation wizard.

Scope of the variable in Uipath RPA :

Scope of the variable is nothing but to what extent an variable is available. For example : people from 10 kilometer always can see Eifel tower, but only people who are 10 meter away can see shops nearby the Eifel Tower as well as Eifel tower.

Similarly Variable also gives access to elements based on the scope we specify.

All the elements can access global variables but if we specify the scope of an variable to a specific flow chart then only that particular flow chart can access and modify that variable, latter variable also called as local variables.

We can promote the variable dcope from local/Activity variables to Global variables, Click on the Activity header and Goto Execute Tab on Menu ribbon, click Promote to Global from Manage variable option.

Once we create variables it will show in the variable tab at the bottom of the UiPath application.
variable-output-uipath-rpa

Create variable from Variable Bottom Tab :

In the above image, there is a additional row for creating the new variable if we click that row, it will add on more row and it enabled for user inputs like variable name, variable value, and scope.

If you right click on a row, application give you option to delete the variable and add Annotation, edit annotation , delete annotation.

annotation-uipath-rpa

Delete : delete will remove the variable row from the variable, if delete it will not throw any warning like "Do you want to delete ?". You can also achieve this by pressing delete button on your computer

Add Annotation : Annotation is nothing but a information regardig the variable, these will be useful if you want to edit any information. Even the employees moves out of team we will have the information about the variable like why and what the variable is about. When we add a variable and pin will added to the row.

annotated-variable-uipath-rpa

Edit Annotation : Edit annotation helps user to alter the given information about the variable.

Delete Annotation : Delete Annotation, removes the annotation from the variable row.

Note : Providing annotation is not mandatory.

Variable Types in UiPtah :


variable-types-uipath-rpa

There are huge amount of data types present in Uipath, but For the user, UiPath shows 4 Types of data which are : Boolean, Int32, String, Object, Array of [T].

In these variable types Array of [T] is the group of same kind of variable types. Boolean type holds the values True, False. Int32 holds all the integer number, 32 is nothing but bytes.

String is nothing but text, like alphabets, alphanumeric. Object is the biggest holder of data, any and everything is object but it is the upper most level.

With help of Browse for Types option opens the other less used variable types, like decimals and other types.
browser-for-types-uipath-rpa

Assign values to Variable in UiPtah :

We can assign default values for a variable and if we donot override the default values then default value remain through out the process.

1. Drag a flow chart into activity area.

2. Pull a sequence next to Flowchart

3. Click on the create variable on the Variable tab in the botton of the UIPath
4. You can assign a Default Value, in case if user doesnot assign any value to this variable, then the value of the variable remain as default
variable-tab-uipath-rpa

5. Now add a Message Box to activity area, inside the Sequence
messagebox-inside-sequence-uipath-rpa

6. Click on the Message Box element and in the Properties area set the Title to "MsG"

7. On the Content field enter the variable name that you have created in the above step.
variable-use-messagebox-uipath-rpa

8. Now run the UiPath robot using run icon or F5.
message-box-uipath-rpa

Assign Value :

Let's do some re-assigning.
9. Drag a Assign element into the Sequence before the Message box, sometimes you need to open Sequence (double click) before pulling the Assign element.

10. Right click on To textbar in the Assign element and select Create Variable option.
assign-value-uipath-rpa

11. Create a variable called site

12. Click on the header of the Assign element, on left side assign the value to the site variable
assign-value-sequence-uipath-rpa

13. On the Message Box Change the content value to site variable.
messagebox-uipath

14. Run the robot now.
msg-mysite-uipath

Variable Types in UiPath RPA

Int32 data type: Variables of this data type are used to store numeric data, It contains only integer number and while giving value we have to enter the value sas plain value without any quotes (single, double).

String data type: String data types store sequence of alphanumeric characters, String data type values are always enclosed in double quotes. You can give only numeric value as well inside a double quotes. You can convert any values to String y using a methods called toString.

You can append the strings using '+' sign, but when you want to append string and number then you have to convert the number into string using toString method, anthen you can use '+' sign. Example : String1 + String2, String1+ integer.toString.

Boolean data type: Boolean type variables support True or False value. Boolean variables mostly used when you want to decide this or that option, so it is extensivly used in Decision making.

If - Else Coditions in UiPath RPA

If else is nothing but the conditional statemenets, it decides, how to proceed further based on given result.

In layman words : You want travel to a distance, you could either use train or car, normally what we do is , if the the distance is 20 miles we take our car and go there but if the distance is more than 20 miles we take train and go to destination. In this example the distance is the deciding factor, so based on this deciding factor we will travel.

Similarly in computerscience we based on the deciding factor we will be doing somework, to achieve this we use conditinal statements.

Deciding factor must result in boolean value i.e either tru or false.

Important Note 0: You cannot write if or else block as seperate activities in UiPath, this is one of the dis-advantages of UiPath

Important Note 1: We can have only on activity inside if activity.

Important Note 2: UiPath will not fail the process just because the value matched / not matched in if..else block. But you can write failing code in side the if or else block to fail the process.

If .. Else :

We would be using If activity, if we want to do something based on your condition match, we may not intended to do any oher task iff the condition is not met.

Example : In below example I want to check, whether a number is more than 50, if so i want to show a Message Box.

Steps :
1. Drag a flowchart.

2. Crate a variable called decidingFactor and set the default value to 70.

3. Drag a If activity in side flow chart
if-condition-uipath-rpa

4. Open If Actvty by double clicking, and Check whether decidingFactor values if more than 50

5. Drag Message Box activity inside Then block and Message box should show "Value is More than 50"

6. Now if the value is more than 50, then the activity inside a if will be executed other wise, UiPath will not perform any tasks present inside then, UiPath moves to else block.

7. On else block Throw a Message Box "Value if Under 50"
if-else-condition-uipath-rpa

8. Run the robot now, using F5 or Run Icon.
if-block-executeda-uipath-rpa

Nested If else block in UiPath RPA :

We can have If..Else block in another if block or in else block, this called as nested if..else blocks

It is similar to If..Else block only but you will have to write condition for all the if blocks.

You may need to Open (double click) the first if block to drag a nested if block. (in below image else block is present but for visibility purpose i have showed only if part)
nested-if-uipath-rpa

Multiple Activities in If or else block :

Most of the time we have more than one activity to perfom in if block, but by defaut if or else block support only one activity and there is no change in that statement.

Donot you think Sequence / FlowChart Activity is one activity ?, donot you think inside Sequence / Flowchart Activity we can write more activities

You are right, we can write multiple activities in side the Sequence and Flowchart, this way you can achieve multiple activities inside if block.

flowchart-inside-if-block-uipath-rpa

Logging in UiPath RPA

How do we know if something goes wrong and execution fails, we need to have the trace of the execution.

The logging helps the user to trace the execution by proving logging messages, Logging could be in different levels like Trace, Info, Warn, Error, Fatal.

The logging print the console in local, but if we are executing the robot in UiPath orchestration, then the log will be printed to elastic search

Just search for "Log Message" on the search element to add the Logger, connect the logger with the Message Box that we created on Message Box in above step.

logger-uipath-rpa
You can run the Robot by pressing F5 and or run icon, Once you run the program it will print the logs onto Output, You can bring the output screen by clicking the output option on left bottom corner of the screen.

On the console you have the print and the filters, using the filters the we can fiter what kind of log we want, or timestpa of logs or we can clear the logs.

output-filter-levels-uipath-rpa

Switch Case & Flow-Switch

The Switch activity enables you to select one choice out of multiple, based on the value of a specified expression.

Switch cases is a condition where the possible paths are defined based on the variable values, Switch case statements are a substitute for long if statements. If can check either true or False condition but Switch can test any condition.

Also switch provides a block for if none of the paths given is matching to a condition then this block will be executed.

The Switch activity can be useful to categorize data according to a custom number of cases.

You can drag and drop the Switch statement into the activity area, and switches can be used only inside sequences and inside Flowchart.

In switch block the Expression textbar is nothing but your condition field, here you can mention a condition or just a variable, based on this result the switch works.

While expression value, you also should take care of the TypeArgument field on the Properties tab. By default, the Switch activity uses the integer (Int32) argument, but you can change it from the Properties panel, from the TypeArgument list.

You can add your cases by clicking on the Add New Case block below the default block, you can n-number of blocks but if none of the block matches then default block will be executed.

You can use sequence or any other activity in these blocks

For Example Purpose I am getting a value from the user and Store it in a variable called brand, based on this brand values I will construct the switch block.

We have to provide title and the Text for the Input box, and input box will expect user to give some value to input dialog, this values will be stored in brand variable.

input-box-uipath
Note : Even though you set the TypeArgument as String, you should provide the case without the string

Inside switch block cases, I have created a message boxes to show the product from the given company.

switch-case-message-box-uipth
Output of the switch case switch-case-output-uipath

Flow Switch

Flow switch is similar to the switch case, but the only difference is that you can use the Flow switch only in the flowchart but not in the Sequence.

We write out Switches based on the portal given in the Flow Switch and we connect out activities to these portals.

Flow chart limits the cases to 12, we cannot have more than 12 cases but incase of Switch we can have as much as we wish.

The first connection you connect from the Flow Switch is always the default case, but you can change it by un-checking the box on the Properties tab

By clicking on any connection would open the Properties tab, in properties tab you can set the case name.

flow-switch-uipath
Output of the Flowswitch activity inside Flowchart. output-of-flow-switch-uipath-rpa
I have used the message boxes but in real time we would be using sequences to write content in switch cases, as the sequences can contain n-number of activities.

Exception Handling : Try Catch in UiPath RPA

An Exception is an unplanned surprise that occurs during execution of program, the exception has power to stop the program execution.

Without a doubt exception stops the execution, but we are more powerful than exceptions, so we can handle the exception without stopping the execution of the program.

Exception occurs when our robot faces an unusual or not expected values or events in the application.

In below example I am trying to assign a genericType Value into Int32 values, not this assignment throws an Exception that we cannot assign. try-catch-error-value-assignment
When we execute the above activities we will get below exception : exception-in-uipath
We can obtain normal flow of program by handling the exception using try catch block.

If these exceptions are not handled properly, the remaining program will not be executed

Try Catch in Ui Path :

Try catch block helps us to handle the exception, with help of try catch we can make the robot to continue the execution even though there is an exception.

We have to write out suspicious activities / exception throwing activities inside the try block, if exception occurs in try block then UIPath makes the control to move into catch block instead of Stopping the process.

Once the robot comes to catch block then robot starts executing the activities in catch block, something like logging, or retrying the same activities in present in try block or just giving soft error message about the exception to the user.

In above Activities add the second assignment inside a try block and add some log statement in the catch block.

We can add n-number of catch blocks for a single try block, there are different types of exceptions and we have to choose our exception carefully so that catch block handle only the intended exception.

But the father of all kind of exception is System.Exception, this exception will accept any kind of exception which occurs in the try block.

Add the TryCatch activity from the Activities search bar

Now after changing the activities, let's execute the Sequence. try-catch-uipath

Finally block :

Finally block is optional block along with try catch block, and if we place some activities in finally block, theseactivities will be executed irrespective of whether the is an exception or not.

Business Exception vs Application Exception :

An Application Exception describes an error rooted in a technical issue, such as an application that is not responding.

A Business Exception describes an error rooted in the fact that certain data which the automation project depends on is incomplete or missing.

Throw new Exceptions :

Read From File in UiPath RPA

File Reading is an important part of automation, as most of the time we will store the details on the file to avoid the compilation of programs

UiPath provides modules to read and write files, in this section we will see how to read the file.

On the element search bar, search for Read Text File and add before Message box, so that we can display the Text present in the File in Message Box.

You need to fill the details about which file you are going to read from the system on Properties tab, it is mandatory property.

read-text-file-uipath
Below is the content of the file readtextfile-uipath-rpa
Once we read the file , we need to store the file content somewhere (not definitely in another file). After read the file content, we have to store the value in variable.

You should set the variable on the content field under output section filecontent-variable-uipath
Click on the message box element and type the variable in on the required field, once you start to variable name, UiPath suggests the available variable names.

variable-usage-uipath-rpa
Now run the robot, and output Message box will look like below. output-read-text-file-uipath-rpa

Send email with UiPath RPA

We can send mails using UiPath, for sending mail we need to configure the SMTP items like Server host and sender, receiver.

Search for the Mail and drag the SMTP mail sender after a flowchart smtp-flowchart-mailsender-uipath
You Need setup your corporate details but for showing an example I am using my details, few private details are masked.

Most of the people make mistake when they enter the details in SMTP config, the most happening mismatch is data type mismatch.

Sometimes we may enter non string value in a string field ( I did this mistake while writing this article ) smtp-setting-uipath
When you run the UiPath robot it may throw an error, saying that authentication failed. In case if you face such error, you will receive an email from the google team saying that they have blocked the sign in.

In the same mail you will link to switch on the permission to allow access, Once click the like you may be navigated to below screen. smtp-error-gmail-uipath
You can use all the details I mentioned but change the sender name and password. Run the Robot after changing the details, and TADA, you will get the mail in your inbox. gmail-received-from-uipath

 
Join My Facebook Group
Join Group
 

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
You can also share knowledge by Adding a topic here


Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions
Copyright © CherCher Tech