Forum Discussion
Multiple AND and OR conditions in the same trigger
Hi,
I made a test file (ST2) to check how trigger's conditions works. The answer is unfortunately: do not mix "and" & "or" conditions. Download and check Yourself.
Seven years later and I have come up with this issue. Thanks for this tester.
I started by modifying the results display:
Note the AND groupings. I worked through different scenarios and the logic seems correct.
Additionally, the current formatting of the trigger conditions lead to this conclusion:
The ANDs are indented, leading me to believe they are evaluated before the ORs.
Can any of our hard-working Articulate reps confirm I am on the right track? Thanks!
- Nedim9 months agoCommunity Member
Let's put it this way: in JavaScript, where && represents AND and || represents OR, the evaluation would follow these rules:
Trigger 1:
let result = (var1 && var2) || (var3 && var4);- If both var1 and var2 are true, result will be true.
- If both var3 and var4 are true, result will also be true.
- If neither of these conditions is satisfied, result will be false.
Trigger 2:
let result = (var1 && var2) || var3 || var4;- If both var1 and var2 are true, result will be true.
- If either var3 or var4 is true, result will also be true.
- If none of these conditions is satisfied, result will be false.
Trigger 3:
let result = var1 || (var2 && var3) || var4;- If var1 is true, result will be true.
- If both var2 and var3 are true, result will be true.
- If var4 is true, result will be true.
- If none of these conditions are met, result will be false.
Needless to say, when both && and || operators are used in an expression/trigger, the AND operator will be evaluated first. I'd say your logic seems correct, but I’d suggest breaking it down the JavaScript way, especially when the conditions in the trigger become complex with too many mixed OR and AND statements.- MattOckenfels-c9 months agoCommunity Member
Thanks Nedim, for the rather complete explanation!
Related Content
- 8 months ago
- 3 months ago
- 7 months ago
- 6 months ago