If-then-else expressions
In this section you will find an example of a more complex expression.
If-then-else operator
The If-then-else operator enables you to build extensive expressions. In the following example, the If-then-else operator is used to display the number of people for a reservation and - if no people are registered for a reservation - to display the text: "No people".
Procedure
1. Add a report for the Reservations business object.
2. Include the Start date, Reservation unit and Description fields in the report.
3. Click the Add expression button to open the Expression builder window.
4. In the Operators section, double-click the ( if ( ) then else ) operator.
The ( if ( ) then else ) operator is added to the Expression section.
5. In the Expression section, place your cursor between parenthesis after 'if'.
6. In the Available fields section, double-click the Number of people field. The expression will look like this:
( if (Orders.'Number of people') then else)
7. In the Expression section, place your cursor after the field 'Orders.'Number of people''.
8. In the Operators section, double-click the > operator and enter a zero (0) directly behind this operator. The expression will look like this:
( if (Orders.'Number of people'>0) then else )
9. In the Expression section, place your cursor between 'then' and 'else'.
10. In the Functions section, double-click the NumToString function. The expression will look like this:
( if (Orders.'Number of people'>0) then numToString() else )
11. In the Expression section, place your cursor between parenthesis of 'numToString' function.
12. In the Available fields section, double-click the Number of people field. The expression will look like this:
( if (Orders.'Number of people' >0) then numToString(Orders.'Number of people') else )
13. In the Expression section, place your cursor after 'else'.
14. In the Constants section, select the Text option.
15. In the Constants section, enter the text "no people".
16. In the Constant section, click the Add button.
The expression has now been completed as you can see from the following example.
17. In the Expression section, click the Check button.
Planon will now check whether the expression you have built is correct.
18. Click OK to save the expression and to close the Expression builder window.
You will now return to the Report definitions and settings window. Your expression has been added to the Selected fields section.
19. In the Selected fields section, select the expression you have just created.
20. In the Settings section, specify the required field settings.
For more information on field settings, refer to
21. View the result in the print preview of the report.
For more examples of if-then-else expressions, see Boolean fields in if-then-else expressions and Combining functions.
Boolean fields in if-then-else expressions
When using a Boolean field in an expression, the construction of this expression should adhere to the following format:
(if (<field of type Boolean>) then xxx else yyy)
Example: (if (Personnel.'Transferred to archive (Y/N)') then "Yes" else "No")