If-Else in XPath

0
Hi, is it possible to use If-Else-conditions in XPath? I can’t find something about this in the Mendix documentation. Thank you! :-)  
asked
3 answers
6

You can write clever XPaths which replicate if-then-else constructions, e.g. if you have a boolean variable called MyBoolean, you can write two clauses, one where the variable has to be true, and one where it has to be false:

[$MyBoolean and _DatumAanmaak > '[%BeginOfCurrentDayUTC%]']
[$MyBoolean = false() and _DatumAanmaak < '[%BeginOfCurrentDayUTC%]']

 

answered
1

No, if-else conditions don’t exist in XPath. It’s more akin to a query language like SQL. Typically, if you need an if-else condition, you can leverage one in a microflow and then perform your retrieve later in the flow.

answered
1

You could try to create your xPath combining the ‘And’ and ‘Or’ operators. An example with booleans:

[Condition1 =  true()]

[(condition 2 = true() or condition 3 = true())]

Condition 1 should allways be true and If either Condition 2 or Condition 3 is true, the object(s) are returned

answered