UiPath Studio Guide

Flowcharts

Flowcharts can be used in a variety of settings, from large jobs to small projects that you can reuse in other projects.

The most important aspect of flowcharts is that, unlike sequences, they present multiple branching logical operators, that enable you to create complex business processes and connect activities in multiple ways.

Example of a Flowchart

To exemplify the properties of a flowchart, we are going to build a guessing game that generates a random number from 1 to 999 that the user must guess. To create such an automation, do the following:

  1. Create a blank project and from the Design tab, in the File group, select New > Flowchart. The New Diagram window is displayed.

Note:

You can also add a Flowchart activity to the Designer panel to create a new flowchart project.

  1. In the Name field type a name for the automation, such as "First Flowchart," and click Create. The Designer panel is updated accordingly.
  2. Create two Int32 variables (intRandomNumber, intGuessNumber) and a String one (strMessage).
  3. Set the default value of the strMessage variable to "Guess a number from 1 to 999." The intRandomNumber stores a random number between 1 and 999, intGuessNumber stores the user’s guess and strMessage stores the message that is going to be displayed to prompt the user.
  1. Add an Assign activity to the Designer panel, and connect it to the Start node.
  2. In the Properties panel, in the To field add the intRandomNumber variable.
  3. In the Value field, type new Random().Next(1,999).

Note:

This field uses the Random() function to generate a random number between 1 and 999. For more information on variables, see Variables.

  1. Add an Input Dialog activity to the Designer panel and connect it to the Assign one.
  2. In the Properties panel, in the Label field, add the strMessage variable.
  3. In the Result field, add the intGuessNumber variable. This activity asks and stores the user’s guesses in the intGuessNumber variable.
  4. 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.
  5. In the Properties panel, in 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.
  6. Add a Message Box activity and connect it to the True branch of the Flow Decision.
  7. In the Properties panel, in the Text field, type "Congratulations! 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.
  8. Add a new Flow Decision activity and connect it to the False branch of the previously added Flow Decision.
  9. 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.
  10. In the DisplayName field, type Comparison. This enables you to easily to tell the difference between the two Flow Decisions used.
  11. Add an Assign activity and connect it to the True branch of the Comparison activity.
  12. 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.".
  13. Select the Assign activity and press Ctrl+C. The entire activity and its properties are copied to the Clipboard.
  14. Press Ctrl + V. A duplicate of the previous Assign activity is displayed.
  15. Connect it to the False branch of the Comparison activity and, in the Properties panel, in the Value field, type "Too small. Try again.".
  16. 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 project should look as in the screenshot below.

Flowcharts