In the action properties, in the Conditions tab, there was also a Type of calculation drop-down at the very top:
It appears when the action has two or more conditions; hence, as far as we are concerned, it was always present; the default action came with two conditions already. Now, let's find out what functionality it offers:
- And: All the conditions must be true for the action to match
- Or: It is enough for one condition to be true for the action to match
- And/Or: Conditions of the same type are evaluated as Or; conditions of different types are evaluated as And
- Custom expression: Full freedom option—you write a formula to define how the conditions should be evaluated
The first two options are clear enough. And/Or automatically creates the expression and the logic is based on condition types. For example, let's say we have the following conditions:
- A: Application = MySQL
- B: Application = PostgreSQL
- C: Trigger severity = High
- D: Host group = Database servers
The And/Or option would create a formula: (A or B) and C and D. This works in a lot of situations, but we might add another condition for a Host group, as follows:
- E: Host group = Production servers
The formula would be (A or B) and C and (D or E). The new Host group condition, being the same type, is or-ed with the previous Host group condition. It is probably not what the user intended, though. In this case, the desired condition was hosts that are both in the database server and production server groups. The And/or option no longer helps help, so we can use a Custom expression. In this case, we would simply type the formula in the input field provided:
(A or B) and C and (D and E)
Grouping for D and E here is optional; we added it only for clarity.