studio
2021.10
false
UiPath logo, featuring letters U and I in white
OUT OF SUPPORT
Studio User Guide
Last updated Nov 18, 2024

Example of Using an If Activity

To exemplify how you can use the If activity, let’s create an automation that asks the user for two numbers, checks to see if one is divisible by the other, and depending on the result, displays a different message in the Output panel.

  1. Create a new sequence.
  2. Create two integer variables, FirstNumber and SecondNumber for example.
  3. Add two Input Dialog activities to the Designer panel.
  4. In the Properties panel, type labels and titles for both activities and, in the Result fields, add the FirstNumber and SecondNumber variables.
  5. Add an If activity to the Designer panel, under the previously added Input Dialog ones.
  6. In the Condition section, type FirstNumber mod SecondNumber = 0. This expression checks if the first number is divisible to the second one, using the mod operator.
  7. In the Then section, add a Write Line activity.
  8. In the Text field, type FirstNumber.ToString + " is divisible by "+ SecondNumber.ToString + ".". This is the message that is displayed if the first number is divisible by the second one.
  9. Click Show Else to display the Else section, and then add another Write Line activity in the Else section.
  10. In the Text field, type FirstNumber.ToString + " is NOT divisible by "+ SecondNumber.ToString + ".". This is the message that is displayed if the first number is not divisible with the second one.


  11. Press F5. The automation is executed.
  12. Add numbers when prompted. Note that the Output panel displays the result, depending on the values added in the Input Dialog windows.




Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.