We can create a new project now. We will create it as “Transactional Process” type.
You can give the project name and description. Also, select the location to save the project.
You can click the “Create” button to create a new project. It will take a few moments to initialize the project dependencies. The project is created with a default flow diagram.
We can remove all the activities from this default flowchart.
In this example project, we will check if a year is a leap year or not. We can get a year value from input dialog box and check the year using “Flow Decision” activity. This “Flow Decision” activity has both a “True” part and a “False” part. If the mod value of the year is zero, the year is a leap year; otherwise not.
We can drag an “Input Dialog” to the work area and give “Title” and “Label” values to this activity.
We can create a variable and select integer as a data type.
We can assign this variable in the “Result” property of “Input Dialog” activity.
We can connect the Start button with Input Dialog. Now, our first flow is created. We can add more flows to this flowchart.
We can add a “Flow Decision” activity to work area and link with flowchart.
We can link this activity to “Input Dialog” activity.
We can add the condition to “Flow Decision” activity. We will check the variable’s mod with four. If the mod is zero, the year is a leap year. Otherwise, it is not a leap year.
As I mentioned earlier, “Flow Decision” has both a “True” part and a “False” part. We will add Message Box to both conditions.
First, we can add a message to the True condition.
We can link previous “Flow Decision” activity with this Message Box.
We can add one more Message Box for False condition and link with Flow Decision activity.
We have completed all the activities for checking given year value is a leap year or not. The entire flowchart looks like below.
We can run the project.
If you give the year like 2018, you will get the below message.
If you give the year like 2020, you will get the below message.
We have seen the usage of Flowchart in the above example. We can see one more example now. We will delete all the existing activities from this project and add new activities to the project.
Modify current project as number guessing the application
We can assign a random number to a variable and get a value from the user. We will check this input value with the above variable and if the values are the same, it will show the message box and exit the application. Otherwise, the system will again check which value is greater and which value is lesser and show the corresponding messages. Again, continue the process and get a new value from the user. If the new value does not match, repeat the process again. The process will end only after the user gives a correct value which will match with a random number, which we have already kept in the variable.
We can start the flowchart.
First, we will create a variable and assign a random number to this variable
We can use “Assign” activity for this purpose. Please drag this activity and assign a variable to it.
We can create a random number and assign this to the Value property of our “Assign” activity. We can use below expression for that.
We have assigned a random value from 0 to 50. We can add “Input Dialog” to guess the user a number between 0 and 50 (You can change it to any random number).
We can assign Result property with a new variable.
We can add a “Flow Decision” activity and check random number with user input.
We can add a message box for True part of the Flow Decision. If the user guesses a value which is equal to a random number, it will show a successful message.
So far, our flowchart looks like below. We must add a few more activities.
We can create a new variable for counting the number of attempts, that user takes for guessing the correct value.
We can add an “Assign” activity to set increment of the above variable.
We will add one more “Flow Decision” activity to check if the user guesses a value which is greater than the random number or not.
If the random number is greater than guessed value, it will show the below message.
If the random number is lesser than guessed value, it will show the below message.
After showing above messages, the process will again ask the user to guess a new value and repeat all these flows again until the user guesses the correct value.
We have completed all the flowcharts. The entire flow looks like below.
We can run the project now. User can enter a value between 0 and 50.
I have given the value as “30”.
It will immediately show the below message.
It will ask one more input value again.
I have given another value, “20,” now.
Now we can analyze that the random number falls between “21” and “29”.
We can try any number between these two numbers. After a few more guesses, I found the exact number.
Please note, we have got the total number of guesses from the counter variable which we have used in our project.
In this article, we have discussed about flowcharts in UiPath and we have seen two simple examples also. I hope you have got a good idea about flowcharts now. It is a very important component in UiPath.
We will see more important features of UiPath in upcoming articles.