Creating boolean expressions

A boolean expression is used in the test attribute of the <when> XML tag.

The boolean expression should evaluate to true or false. When the expression evaluates to true, the corresponding <when> condition is met, the content between the <when> and </when> XML tags will be executed.

The most basic form of a boolean expression is:
left_operand operator right_operand

where operator is one of the logical or comparison operators. Similar to most programming languages, you can use a combination of operators to operate on a number of operands, to create more complex boolean expressions.

For example, the following boolean expression will test whether the person's last name is Smith:
id.222.response.TCRMPersonNameBObj.LastName = 'Smith'
Note: In the preceding example, the left operand is very similar to the backward reference format used in substitution expressions. If you are not familiar with substitution expression and backward reference, refer to Example: Substituting values from another Request or Response before continuing with this section.
A slightly more complex boolean expression is:
id.222.response.TCRMPersonNameBObj.LastName = 'Smith' and
id.222.response.TCRMPersonNameBObj.GivenNameOne = 'John'
This boolean expression will test whether the person's last name is Smith and first name is John.

Understanding the position of the operand

In some programming languages, there is no restriction on whether an operand appears on the left side or right side of the operator. For example, the expression LastName = 'Smith' and the expression 'Smith' = LastName are both allowed. This is, however, not the case with boolean expressions used in composite XML transactions.
In composite XML transactions, the left side operand in a boolean expression can only be one of the following:
The right side operand can only be one of the following:

If the wrong type of operand appears in the boolean expression, an exception will be thrown at parsing time.

Understanding supported functions

The framework supports two functions that can be used in expressions:
  • count
  • date

The format of the count function is count(argument), where argument is a backward reference to a business object. The count function returns a numeric value that equals to the number of occurrences of the specified business object.

For example, to test if there is no TCRMPersonSearchResultBObj returned in a response:
count(id.111.response.TCRMPersonSearchResultBObj) = 0
Note: The count function can only be used in the left operand in an expression.

The count function is intended to test the number of occurrences in a collection, hence the argument is expected to resolve to a collection at runtime. If the argument resolves to a single instance, the count function will throw an exception.

The format of the date function is date(argument), where argument is the string representation of a date. The date function ensures that the string argument can be converted into a date object.

For example, to test if the LastUpdateDate is equal to a specific date:
id.111.response.TCRMPartyBObj.PartyLastUpdateDate = date('2005-12-31 12:00:00.000')
Note: The date function can only be used in the right operand in an expression.

Understanding supported keywords

The only supported keyword is null. Use the null keyword with another backward reference to test whether that reference exists or not.

For example, to test if the person's alert indicator has not been set:
id.111.response.TCRMPersonBObj.AlertIndicator = null
To test if the person has no financial profile:
id.111.response.TCRMPersonBObj.TCRMFinancialProfileBObj = null
Note: The null keyword is intended to be used with a backward reference that resolves to a single instance. If the backward reference resolves to a collection, an exception will be thrown.