In UiPath, the If statement is exactly how you’d expect it to be:
- The condition that is verified (with 2 potential outcomes – true or false
- The set of actions to be executed when the condition is true (the Then branch)
- The set of actions to be executed when the condition is false (the Else branch)
- The If Statement in sequences
- The Flow Decision in flowcharts
- Using VB .Net operator
What are some business scenarios in which I will use the If statement?
Whenever there are two courses of action that are not arbitrary, an If statement will most likely be used:
- Checking the status of a payment (done/not done) and performing a set of operations in each case
- Making sure that the outcome of the previous operation in the sequence is successful
- Checking the balance of an account to ensure that there is enough money to pay an invoice
- Checking if something has happened in a system, like if an element or an image exists and performing an action based on that.
Example: Business purpose we need to check if the year is leap year. An year is leap year if it meets the below conditions, if:
- The year is evenly divisible by 4
- The year can be evenly divided by 100, it is not a leap year, unless the year is also evenly divisible by 400
1) Using If Else Activity
2) Using Flow Decision
Add the same VB condition in Flow Decision -> condition option in properties panel
3) Using VB.net
- Create Sequence, Add INput dialog to enter year
- Create 2 variables year and message
- Add assign activity and in the value add the VB.net expression
Robot will look like
We can have nested if in if statements.
More info on IF
More info on Flow Decision
No comments:
Post a Comment