Conditions and flow control

From FlexRule Wiki
Jump to: navigation, search

These commands are related to Procedural logic.

If-ElseIf-Else

Generally in a procedural approach you come across a situation you need to compare values. And based on that comparison you need to carry out a task or decision. In these situations where comparison is required, If command can be used.

For example the following command checks whether the age of a person is less that 18.

  1. <If condition="person.Age  lt 18">
  2.     <!-- Action comes here -->
  3. </If>

In condition part of If an Expression is expected.

Branching Multiple Conditions

There is also possibility to have nested If(s) and if their conditions are mutually exclusive (they cannot be all true) then you can use ElseIf command instead. And for exclusion part of the chain of conditions Else may be used.


  1. <If condition="person.Age  lt 18">
  2.     <!-- Action comes here -->
  3.  
  4.     <ElseIf condition="person.IsMale">
  5.         <!-- Action for this condition -->
  6.     </ElseIf>
  7.  
  8.     <ElseIf condition="person.IsFemale">
  9.         <!-- Action for this condition -->
  10.     </ElseIf>
  11.  
  12.     <Else>
  13.         <!-- Default action -->
  14.     </Else>
  15. </If>

Please note ElseIf and If/Else should be covered by an initial condition using If.

Repeaters

Do

While