Skip to main content

<if>

Evaluate a condition and perform one action if true, another if false.

Syntax

<if condition="1">
   <true>
     ...
   </true>
   <false>
     ...
   </false> 
</if>

Attributes and Elements

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.

Specify an expression that evaluates to 1 (if true) or 0 (if false).

LanguageOverride attribute

Optional. Specifies the scripting language in which any expressions (within in this element) are written.

Can be "python", "objectscript", or "basic" (not documented). Default is the language specified in the containing <process> element.

name, disabled, xpos, ypos, xend, yend attributes
<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.

See Also

FeedbackOpens in a new tab