IF Function
The IF function allows you to evaluate a condition and then do one thing if the condition is true, or a different thing if the condition is false. Commonly referred to as If-Then-Else, your logic inside an expression can be simple to complex, and the result represents whether or not the condition is true.
Find the IF function in the Context Browser > Function tab > Logical section and drag it into any Type/Drop field. Then, in the Smartfield Composer, type or drag Fields, Functions, SmartObjects, or Workflow-related properties from the Context Browser to configure your IF function. For advanced configuration, including nesting conditions, click the Edit in Rules Designer button to launch the advanced Rule editor.
Example of an IF Function
- Expand the Context Browser and select the Functions tab. From the Logical section, click and drag the IF function into a Type/Drop field.
- The Smartfield Composer opens.
The following table explains the available options:
Option Explanation How to Use If
Use the If fields to specify the condition. The If part contains three sections: two fields and an operator. In the left field you specify what value is evaluated (the 'Sky' variable, in the example above), and in the right field specify the value to test against ('Blue', in the example above). Then use the operator to define your comparison statement ('equals' in the example above). Select any of the following operators:- Equal, Not Equal
- Greater Than, Greater Than or Equal
- Less Than, Less Than or Equal
- Starts With, Ends With
- Contains
Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields.
Hover over the equal (=) sign to show the down arrow. Click and select a different operator from the menu.
Then
In the Then field, specify what happens when the tested condition results in true.In this example: If the Sky is Blue then it is Day
Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields.
Else
In the Else field, specify what happens when the tested condition results in false.In this example: If the Sky is not Blue then it is Night.
Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields.
Edit Rules Designer Use the Rules Designer to create more complex conditions. You can add more conditions and build nested or 'fall-through' IF-THEN-ELSE statements. Click the Edit Rules Designer button to expand the rules designer canvas.
From the Rules Toolbar, drag a Condition or IF/ELSE statement onto the design canvas.
Type values or create dynamic values by dragging Functions, Fields, SmartObjects and Workflow-related items from the Context Browser into the fields.
Use the Trash bin to delete any unwanted conditions dragged onto the design canvas.
- Use the configure section in the Smartfield Composer to construct a simple If-Then-Else condition.
- Use the rules designer to build more complex condition. Click Edit in Rules Designer to expand the Rules Designer Panel.
- To configure the complex condition, use the Rules Toolbar to drag additional conditions and If-Then-Else statements onto the rules designer canvas. Use the Quick Insert Toolbar to instantly add a block to the rule you are working on. Use the Trash bin to delete any unwanted items dragged onto the canvas.
For information on creating complex condition, see Configure a simple or complex If-Then-Else expression using the IF Function.
- Click Done Editing to close the Rules Designer panel.
Example of a complex configuration using multiple conditions
- You'll notice a Complex block in configure section. This block indicates that you created a more complex condition. Click Edit Rules Designer to see and edit it.
- You can change the title to make it easier to identify your function. Click the header and type a title.
- When done, click X to close the Smartfield Composer.
When working with the If-Then-Else statement keep in mind the following considerations:
- You can use the If-Then-Else expression in nested expressions
- When you use the If-Then-Else expression in the Rules Designer you are only able to configure a simple IF condition That includes configuring a custom rule for any of the following rule types: Recipient Rule, Result / Voting Rule, Decision Rule, Split Rule, Conditional Start Rule, and Merge Rule. This means that when you drag the IF function into a field within the Rules Designer, the Edit in Rules Designer button is disabled, meaning you cannot add or customize additional conditions
- If you need to create a more complex If-Then-Else expression in the Rules Designer, drag an IF/THEN structure block from the Rules Toolbar (at the bottom of the Rules Designer screen) into the rule you are designing instead of using the Context Browser