Page History
Problem
Assume you want to make an attribute (e.b) depending on another attribute (e.a). The latter is multivalued with two values in a value list: 'v' and 'w'. This situation is depicted in the following screenshot:
What should the expression be to show the attribute 'e.b' in case 'e.a' is either 'v' or 'w'?
Expectation
One would expect that the following precondition expression is correct:
Code Block | ||
---|---|---|
| ||
e.a = [ "v" , "w" ] |
And indeed it works for the following cases:
- if 'e.a' is UNKNOWN, 'e.b' will also be evaluated to UNKNOWN
- if 'e.a' = "v", 'e.b' will be shown
- if 'e.a' = "w", 'e.b' will be shown
- if 'e.a' = "v" and 'e.a' = "w", 'e.b' will be shown
However if we deselect both options (this can be done by clicking on the entries of 'e.a' by holding ctrl) in the profile the value for 'e.a' = [] (an empty list). In that case 'e.b' is shown. This is because the expression e.a = [ "v" , "w" ] lead to TRUE. The reason for this is that this notation checks whether the first part before the '=' sign is a subset of '[ "v" , "w" ]'. And because an empty list is always contained in a filled list, it is always TRUE. Even if you would ask the runtime expression evaluator for the following expression:
Code Block | ||
---|---|---|
| ||
e.a = [ "Hello world" ] |
under the same conditions, it will result to TRUE.
Solution
...
bgColor | #fff |
---|
The solution is to use another expression. There are multiple other ways to receive the desired behavior, we show some of them:
Code Block | ||
---|---|---|
| ||
1) e.a = "v" OR e.a = "w"
2) e.a != [""]
3) SIZE(e.a) != 0 |
...
UI Expand | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||||||||||||
|
...