- Getting Started
- Before You Begin
- How To
- Build Your First App
- Build a Mobile-friendly App
- Embed Apps
- Embed Maps
- General User Experience Guidelines
- Hide Containers Using a Button
- Include Excel Charts in Apps
- Include MailTo Links
- Include Star Ratings
- Use Count With Choice Set Values
- Use Document Viewer
- Use Master Detail View
- Use Selected Values From a Table
- Use the Send Interim Result Activity
- Set External Context
- Work With Data Source and Value Bind
- Notifications
- Designing your App
- Events and Rules
- Rule: If-Then-Else
- Rule: Open a Page
- Rule: Open URL
- Rule: Close Pop-Over/Bottom Sheet
- Rule: Show Message
- Rule: Show/Hide Spinner
- Rule: Set Values
- Rule: Start Process
- Rule: Upload File to Storage Bucket
- Rule: Get File From Storage Bucket
- Rule: Reset Values
- Rule: Create/Update Entity Record
- Rule: Delete Entity Record
- Rule: Add to Queue
- Function: And, Or, Not
- Function: Concat
- Function: Contains
- Function: Count
- Function: EndsWith
- Function: If
- Function: IsBlank
- Function: Guid
- Function: Length
- Function: List
- Function: StartsWith
- Function: Sum
- Function: Sort
- Function: Now
- Function: Today
- Function: Time
- Function: Year
- Function: Month
- Function: Day
- Function: Hour
- Function: Minute
- Function: New
- Function: Lookup
- Function: Filter
- Leveraging RPA in your App
- Leveraging Entities in Your App
- Leveraging Queues in Your App
- Application Lifecycle Management (ALM)
- Basic Troubleshooting Guide
Rule: If-Then-Else
Provides support for conditional statements
We often want to "conditionally" do things in our app, for example if the value of a label is <0, we want it to be red. We can do things conditionally in our app using the if-then-else statement combined with conditional expressions.
In Apps Studio, the If-Then-Else rule allows you to specify:
- the condition(s) to check (that's goes in the If statement)
- what happens if the condition is true (that's goes in the Then statement)
-
what happens if the condition is false (that's goes in the Else statement)
There are two kinds of conditional statements that can be used inside the If:
- Compare: Used to compare two values.
- Group: Used to group multiple comparisons (And/Or).
The compare function allows you to write a conditional expression - something that evaluates to true or false.
Each condition specifies two values to compare and a comparison operation.
These values can be:
- a reference to a control property
- a static value (i.e. a number or a string)
The comparison operation must be one of the following:
Comparison operation |
Symbol |
Description |
Example |
---|---|---|---|
Less than |
< |
Returns true if the left value is less than the right value |
3 < 6 |
Less than or equal |
≤ |
Returns true if the left value is less than or equal to the right value |
Cash In Value ≤ 0 |
Greater than |
Returns true if the left value is greater than the right value |
5 > 2 | |
Greater than or equal |
≥ |
Returns true if the left value is greater than or equal to the right value |
Cash Out Value ≥ 0 |
Equal |
= |
Returns true if the left value is equal to the right value |
State = WA |
Not Equal |
≠ |
Returns true if the left value is not equal to the right value |
Transaction Id ≠ 0 |
The Group function allows you to combine multiple conditional expressions together. This allows us to make more complex conditional expressions like "if both X and Y are true" or "if either X or Y are true" in our apps.
Group allows you to group multiple comparison statements together using logic.
The Then and Else statements can be any rule, meaning you can nest statements.
Scenario: When the "Submit" button is clicked, a process runs and returns a transaction ID. The text color of the "Transaction ID" label should be red if the deposit is less than 0, otherwise, it should be green.
The text color of the "Transaction ID" label should be red if its value is less than 0, otherwise, it should be green.