If-Then-Else Actions
If-Then-Else actions are used to execute a variety of actions based on different criteria. They function as a container action that holds other actions. You define criteria that control when one or multiple actions run, and the If-Then-Else action groups those actions into a single action. If-Then-Else actions are the most commonly used action and offer the following advantages:
- Reduce the number of rules in the system by grouping similar actions together in a single rule where they can all be seen and maintained.
- Provide a quick, GUI-based programming tool.
- Allow admin users to define multiple conditions, each of which can run different actions of any type when the condition is true.
- Allow multiple clauses to be embedded within each other, separating or combining them with “and” and “or” operators to create complex conditional statements.
Example
Consider a rule that runs when a new record is created in the Service Requests table using this If-Then-Else action:
- If the Assigned Person field does not equal null, meaning it isn't empty,
- Email the Assignee about the new request.
- Else, if the Assigned Team field does not equal null, meaning it isn't empty,
- Email the Assigned Team the new request.
Create an If-Then-Else Action
You can access the Actions wizard in several ways, but the easiest way is to select Setup [Table] from the table where you want to create the action.
- From the top nav bar, expand the table's drop-down and select Setup [Table].
- Select the Actions tab in the Table wizard.
- Click Create If-Then-Else Action.
On the General tab, name your action and give it a description. For example, you might say, "Handles team assignments based on Category." This can be helpful if you inherit someone's system, are working with someone else, or want to quickly know the action's purpose without examining the conditions.
Once your action is saved the system automatically adds an I: before your given title to distinguish the action as If-Then-Else.
Navigate to the Details tab and use the Add buttons to create your unique If-Then-Else criteria. When adding actions, you can modify existing actions or create new ones.
- Click Finish.
Working with the Details Tab
When creating If-Then-Else Actions, most of your time is spent creating your action's criteria on the Details tab. Use the buttons in the editor to define conditions and then add actions that run when the conditions are met.
Add Action
The Add Action button opens the Actions screen and allows you to insert actions into your conditions. To add the first action to a condition, select a row with an ellipsis and click Add Action. Make sure to add at least one condition before you start adding actions to avoid having to delete and recreate any lines.
If you're adding an action and have an existing action selected that's within a condition, the new action is added directly below the existing action, within the same condition. If you have the condition statement selected, the action is added below, outside the condition.
If you need to nest an If-Then-Else action inside another If-Then-Else action, be careful when switching between them. Always make sure you're working in the right window.
Add If
The Add If button inserts an if
condition. Conditions are inserted beneath the row you have selected. If the selected row is contained within a condition, the new if
condition is also contained within that condition.
Clicking Add If opens the Filters screen where you can use any filter to create your if
condition. When you create the filter and click Finish, a description of the filter is inserted in parentheses after the if
condition. For more information on creating filters, see Creating Saved Searches, which are built the same way.
Add ElseIf
The Add ElseIf button inserts an else-if
condition. Inserting an else-if
condition works like inserting a regular if
condition, placing the condition below the selected row. Clicking the button opens the Filters screen, and a description of the filter is inserted in parentheses when added.
An else-if
condition can be thought of as subsidiary to an if
condition. An else-if
condition says that if the previous condition, the if
condition, is false, only then check if the else-if
condition is true.
Add Else
The Add Else button inserts an else
condition. Unlike if
and else-if
conditions, else
conditions do not use filters, so else
conditions immediately insert a space for an action. An else
condition can be thought of as subsidiary to both if
and else-if
conditions.
An else
condition says that if the other conditions are false, only then execute the action defined in the else
condition.
Add Comments
The Add Comments button inserts comments within the dialog box, which lets you explain the conditions and actions. It's not always easy to understand If-Then-Else actions when you first see them, so providing comments can help other admins troubleshoot, adjust, or extend the action in the future.
Comments are added below the condition of the selected row, and they're formatted with two forward slashes. When you click Add Comments, a pop-up appears where you can write the comment.
Move Up and Move Down
The Move Up and Move Down buttons move conditions and actions within the dialog box. You can freely move actions up and down throughout the dialog box, but conditions have some caveats. Most notably, if
conditions can be moved up and down, but they cannot be moved past other if
conditions. Moving an if
condition to another if
condition places it inside that second if
condition. An if
condition inside another if
condition can't be taken out of it. The else-if
and else
conditions cannot be moved at all. If you need to move conditions that can't be moved, you need to recreate the condition in the correct location and then delete the one in the wrong location.
For these reasons, you should think through your logic carefully before building an If-Then-Else action.
Edit
The Edit button allows you to edit existing conditions. Clicking the button brings up the Filters screen, where you can make changes to the filters as desired.
You cannot directly edit actions with the Edit button. To edit an action, you need to do so from the Actions wizard, which you can access from the Actions tab of the Table wizard, the Rules wizard, or the Field wizard for action buttons.
Delete
The Delete button removes conditions and actions from the If-Then-Else action. If you delete a condition, you also delete any conditions or actions contained within that condition. Actions that are deleted are still available in the system; they are only removed from the If-Then-Else action.
Useful Tips
Before creating an If-Then-Else action, consider the following:
- You cannot move an
if
condition up to the top level of your statement once it has been created. As a workaround, see Moving an If Condition to the Top Level below. - Placing
if
s at the correct level can sometimes be a challenge. Until you are familiar with the editor, we suggest checking the screen after clicking Add If to make sure the order is correct. Searches within an If-Then-Else action do not find changes made by earlier actions within the same If-Then-Else action.
Example
Suppose the first action contained in an If-Then-Else action sets the Assigned Person to John Smith, and a later
if
condition says “if the Assigned Person equals John Smith, then email John Smith that he has been assigned.” The second search will not find the record where John Smith was just assigned. Changes made by an If-Then-Else action are saved in memory and executed after all theif
s have been evaluated.
Moving an If Condition to the Top Level
It's difficult to insert a new if
condition above the first if
condition in an If-Then-Else action, and you cannot do so by simply moving the if
condition up to the top level. To get an if
condition to the top level, you first need to figure out the action you want to run with it. Once you have the action in mind, follow these steps:
- Click Add Action to insert the action you want to run with the new
if
condition. - Select the action row, and click Move Up repeatedly until you move the action to the very top row.
- With the action row selected, click Add If. This inserts the
if
condition immediately below the action. - Enter your criteria for the criteria and click Save.
- In the dialog box, select the action and click Move Down to move it below the
if
condition. The newif
condition is now at the top level.