Business Process and Data Transformation Language Reference
<if>
[Back] [Next]
   
Server:docs1
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Evaluate a condition and perform one action if true, another if false.
Synopsis
<if condition="1">
  <true>
    ...
  </true>
  <false>
    ...
  </false>
</if>
Details
Attribute or Element Description Value
condition attribute Required. An expression that, if true, causes the contents of the <true> element to execute. If false, the contents of the <false> element are executed. An expression that evaluates to the integer value 1 (if true) or 0 (if false). This expression must use the scripting language specified by the containing <process> element.
name, disabled, xpos, ypos, xend, yend attributes See Common Attributes and Elements.”  
<annotation> element
<true> element Optional. If the condition is true, activities inside the <true> element are executed.  
<false> element Optional. If the condition is false, activities inside the <false> element are executed.  
Description
The <if> element evaluates an expression and, depending on its value, executes one of two sets of activities (one if the expression evaluates to a true value, the other if it evaluates to a false value).
The <if> element may contain a <true> element and a <false> element which define the actions to execute if the expression evaluates to true or false, respectively.
If both <true> and <false> elements are provided, they may appear within the <if> element in any order.
If the condition is true and there is no <true> element, or if the condition is false and there is no <false> element, no activity results from the <if> element.
The following example shows an <if> element used to coordinate the results of a combination of <call> and <sync> elements used together.
<sequence name="thread1">
  <call name="A" />
  <call name="B"  />
  <sync calls="A,B" type="all" timeout="10" />
  // Did the synchronization time out before it finished?
  <if condition='synctimedout="1"'>
    <true>
      <trace value="thread1 timeout: Call A or B did not return." />
    </true>
    // If not, then the calls came back, so assign the results.
      <false>
        <assign property="context.TheResultsFromEast"
                value='syncresponses.GetAt("A")'
                action="append"/>
        <assign property="context.TheResultsFromWest"
                value='syncresponses.GetAt("B")'
                action="append"/>
      </false>
    </if>
  </sequence>
The <if> activity in this example has a condition that tests the execution context variable synctimedout against the integer value 1. synctimedout can have the value 0, 1, or 2 as described in the documentation for <call>. If the two values are equal, this <if> condition receives the integer value 1 and statements inside the <true> element are executed. Otherwise, statements inside the <false> element are executed.
Note:
There is more information about the business process execution context in documentation of the <assign> element.