BEA Logo BEA WebLogic Process Integrator Release 1.1

  Corporate Info  |  News  |  Solutions  |  Products  |  Partners  |  Services  |  Events  |  Download  |  How To Buy


   WebLogic Process Integrator Doc Home   |   Studio Guide   |   Previous Topic   |   Next Topic   |   Contents   |   Index

Using Expressions and Conditions


The following sections explain how to use the WebLogic Process Integrator Expression Builder and expression components:


Workflow Expression Functionality

A workflow expression is an algebraic expression that defines a calculation that the WebLogic Process Integrator system performs at run time. Workflow expressions use syntax comparable to that of Structured Query Language (SQL). SQL is the international standard language for manipulating information in relational database management systems. This type of syntax makes it easy to manipulate strings, test for relationships and conditions, and perform arithmetic calculations involving workflow variables, database fields, and literal values (constants).

The result of an expression may be a string, a string representation of an integer, double, date/time value, or either of the Boolean (logical) values TRUE and FALSE. Expressions that yield a Boolean result are variously referred to as conditional expressions or conditions.

You can use workflow expressions, as described in the following sections.

Generate a String That Uniquely Identifies a Workflow Instance

Consider a workflow named "Registration of Invoice," concerned with the process of registering invoices. Instances of the workflow can be uniquely identified by appending the invoice number and date to this workflow name. The following expression yields a string that, when appended to the workflow name, provides an informative description of the workflow instance:

"#" + :'Invoice #' + ", dated " + :'Invoice Date'

where 'Invoice #' and 'Invoice Date' are the names of workflow fields.

This expression might yield the following workflow instance name:

"Registration of Invoice # 12345, dated May 16, 1999"

Determine Whether a Particular Event Should Trigger a Workflow

Consider a customer credit review workflow that should be initiated if the current balance due exceeds 75 percent of the customer's credit limit. The workflow is triggered by the arrival of an XML document indicating that a customer record in the underlying Accounts Receivable application has changed.

If the XML document "customer" contains elements called balance_due and credit_limit_amount, the expression required to detect this condition in the XML document is:

ToDouble(XPath("/customer/balance_due/text()")) > ToDouble(XPath("customer/_credit_limit_amount/text()")) * .75


Using the Expression Builder

The Expression Builder enables you to build expressions to be executed in WebLogic Process Integrator at run time. Expressions are made up of functions, operators, literals, and variables. These expression components are discussed in Using Expression Components.

The Properties dialog boxes for workflow components have an Expression Builder button, shown in the following figure. You click the button to display the Expression Builder dialog box.

Figure 6-1 Expression Builder Button

Figure 6-2 Expression Builder Dialog Box

To build an expression, either type it directly in the Expression field using SQL language or use the functions, operators, literals, and variables options to build the expression. Selecting a component from the scrollable list to the right and clicking OK places the appropriate expression text in the Expression field.

If the expression is valid, the message "Expression is valid" appears in the Expression Builder dialog box; otherwise, an error message is presented in a dialog box. Note that validation does not check the validity of workflow variable referenced by the expression, nor does it check for the correct number of parameters being passed to a function, nor does it attempt to do type checking. If there is a type mismatch in the expression (for example, performing arithmetic on a non-numeric string), a run-time error results when the expression is evaluated.

If you enter an invalid expression, the system displays a message that attempts to explain why the expression is invalid. The following table lists the messages that may be encountered, together with possible causes.

Table 6-1 Invalid Expression Messages


Possible Cause(s)

Invalid <operator> operand

One or both of the operand(s) to an AND, OR, XOR, NOT,*,/,%,+,-,<,<=,=,<>,>=,> operator was not valid. For example, attempted arithmetic on a non-numeric string: "Name: " * 25.4.

Mismatched operand types in <operator> comparison

Attempting to compare values of different types. For example, comparing a date to a number: {97/09/30} <= 56.9.


A string representation of a number did not have the required format for the type of number. For example: 1.23ZX.

Invalid function name

The expression calls an undefined function. For example: "Name: " + somefunc(:var). somefunc is not a valid function name.

Incomplete escape sequence

The last character in a quoted string was a backslash character that was not followed with one of the following characters: r, n, f, t, \, ', ",0

Invalid escape sequence

A quoted string contained a backslash character that was not followed with one of the following characters: r, n, f, t, \, ', ",0

Fatal error

An internal error occurred in the expression evaluator. The expression probably contains a syntax error.

Unclosed string

A string literal did not have a matching quote at the end. In the following example, a double quote is not matched by a single quote: `This is an unclosed string'.

Illegal character

The expression contains a character that violates the syntax of the expression language. In the following example, ! is the invalid character: 7 * :wks + " days" !

Error: unmatched input

The evaluator could not interpret the expression. The expression probably contains a syntax error.

Unrecoverable syntax error

The expression contains an invalid token. In this example, name is invalid because the + operator was omitted: "Name: " name.

The Expression should have been: "Name: " + name.


Using Expression Components

Expressions are made up of functions, operators, literals, and variables.


WebLogic Process Integrator provides the following functions, which can be used by the workflow developer to construct conditions.


Returns the absolute value of the expression.


expression is a workflow expression for which the absolute value is to be calculated.


Returns current system date.



Performs date arithmetic.

DateAdd(date, interval, number [, buscal])

date is the base date.

interval is the unit of time to use. Possible values are:

Table 6-2 Interval Values
















business hours


business days

The interval is not case sensitive except for "m" and "M".

number is the number of units to add (or subtract).

buscal is the name of the business calendar to be used for the business hours and business days calculation. If no calendar is specified, the default calendar is used.


Converts a date to a string.

dateToString(date, format)

date is the date to be converted to the string value.

format is a string specifying the format of the string.


Provides the string length.


string is the string for which a length will be provided.


Converts a string to a date.

stringToDate(string, format)

string is the string to be converted to the date value.

format is a string specifying the format of the string.


Extracts a sub-string from a string.

SubString(string, start [,length])

string is the string from which the sub-string is to be extracted.

start is the starting position in the string. (The first position is 1.)

length is the length of the sub-string. This is an optional parameter. If it is not included, the substring extracted will be the rest of the string.


Provides the task attribute.

TaskAttribute(attribute [,taskname])

attribute is the task attribute.

The following table identifies the construction for inserting system maintained workflow information into an expression:

Table 6-3 TaskAttribute Expressions



task instance ID


user ID of assignee


priority set by application


task overdue date


name of task


task-start date/time


completed date/time


application comment



Provides the workflow attribute.

attribute is the workflow attribute.

The following table identifies the construction for inserting system maintained workflow information into an expression:

Table 6-4 TaskAttribute Expressions



workflow instance ID


workflow template ID


template definition ID


workflow initiator


parent workflow ID


workflow name


start date/time


completed date/time


ID set by application


application comment



Returns the value of a workflow variable for a particular workflow instance.

workflowVariable(instanceid, variable)

instanceid is the workflow instance Id.

variable is the workflow variable.


XPath(xpathstring, xmldocument)

xpathstring is the xpath expression

xmldocument is the name of the variable that contains the XML document on which the expression is evaluated. This parameter can either be of XML type or string type. This parameter is optional. If it is not specified, the XML document is assumed to be the incoming XML event.

XPath is a language for addressing parts of an XML document. It provides basic facilities for the manipulation of strings, numbers, and Booleans. XPath gets its name from its use of a path notation as in URLs for navigating through the hierarchical structure of an XML document. To obtain the official specifications of the XPath language, refer to the following Internet site:

To obtain a quick reference guide to XPath notations and functions, refer to the following Internet site:

The following are examples of the most common uses of XPath for retrieving
text values from nodes, attribute values, selecting sub trees, selecting nodes by attribute value and so on from an XML document. Consider the following XML document:

Listing 6-1 Common Uses of XPath

<?xml version="1.0"?>
<b name="bill">This is the first value</b>
<d id="d1">This is the second value</d>
<d id="d2">This is the third value</d>
<d id="d3">This is the fourth value</d>
<d id="d4">This is the fifth value</d>

To select the textual value of the <b> element (i.e., "This is the first


To select the textual value of the <d> element whose id attribute has the
value "d3" (i.e., "This is the fourth value"):


To select the textual value of the second <d> element (i.e., "This is the
third value"):


To select the value of the name attribute of the <b> element (i.e., "bill"):


To select the entire <c> subtree (i.e.,


<d id="d1">This is the second value</d>

<d id="d2">This is the third value</d>

<d id="d3">This is the fourth value</d>

<d id="d4">This is the fifth value</d>



Date Function Format

To specify the date format, use a time pattern string to describe dates and times. For example, the following time pattern string:

"yyyy.MM.dd G 'at' hh:mm:ss z"

results in the following formatting:

2000.07.31 AD at 13:10:35 PDT

This section describes pattern letters, provides formatting guidelines, and shows examples.

Pattern Letter Definitions

In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following.

Listing 5 Pattern Letter Definitions

Symbol   Meaning               Presentation     Example

------   -------               ------------     -------

 G        era designator        (Text)           AD

 y        year                  (Number)         1996

 M        month in year         (Text & Number)  July & 07

 d        day in month          (Number)         10

 h        hour in am/pm (1~12)  (Number)         12

 H        hour in day (0~23)    (Number)         0

 m        minute in hour        (Number)         30

 s        second in minute      (Number)         55

 S        millisecond           (Number)         978

 E        day in week           (Text)           Tuesday

 D        day in year           (Number)         189

 F        day of week in month  (Number)         2 (2nd Wed in July)

 w        week in year          (Number)         27

 W        week in month         (Number)         2

 a        am/pm marker          (Text)           PM

 k        hour in day (1~24)    (Number)         24

 K        hour in am/pm (0~11)  (Number)         0

 z        time zone             (Text)           Pacific Standard Time

 '       escape for text

 ''      single quote                              '

Format Guidelines

The count of pattern letters determine the format.

Any characters in the pattern that are not in the ranges of ['a'..'z'] and ['A'..'Z'] will be treated as quoted text. For instance, characters like ':', '.', ' ', '#' and '@' will appear in the resulting time text even though they are not within single quotes.

A pattern containing any invalid pattern letter will result in a thrown exception during formatting or parsing.

Examples of Time Patterns

Listing 6 Examples Using the US Locale

Format Pattern                         Result

--------------                         -------

"yyyy.MM.dd G 'at' hh:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT

"EEE, MMM d, ''yy"                ->>  Wed, July 10, '96

"h:mm a"                          ->>  12:08 PM

"hh 'o''''clock' a, zzzz"         ->>  12 o'clock PM,Pacific Daylight Time

"K:mm a, z"                       ->>  0:00 PM, PST

"yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM


The following table describes the available operator values:

Table 6-7 Operator Values


Actual Value






expr1 AND expr2


True if expr1 and expr2 are both True; otherwise False



expr1 OR expr2


True if either expr1 or both expr1 and expr2 are True; otherwise False



expr1 XOR expr2


True if either but not both expr1 or expr2 are True; otherwise False



NOT expr


True if expr is False; otherwise False




Any expression

Evaluates expr first



expr1 * expr2


Numeric product



expr1 / expr2


Numeric quotient



expr1 % expr2


Numeric modulus (remainder when expr1 divided by expr2)



+ expr

expr1 + expr2


String or numeric

Unary plus

String concatenation or numeric addition



- expr

expr1 - expr2



Unary minus (negates expr)


Less than


expr1 < expr2

String or numeric

Logical True if expr1 is less than expr2; otherwise False

Less than or equal to


expr1 <= expr2

String or numeric

Logical True if expr1 is less than or equal to expr2; otherwise False

Equal to


expr1 = expr2

String or numeric

Logical True if expr1 = expr2; otherwise False

Not equal to


expr1 <> expr2

String or numeric

Logical True if expr1 is not equal to expr2; otherwise False

Greater than


expr1 > expr2

String or numeric

Logical True if expr1 is greater than expr2; otherwise False

Greater than or equal to


expr1 >= expr2

String or numeric

Logical True if expr1 is greater than or equal to expr2; otherwise False

Logical operators AND, OR, XOR, and NOT are valid only when the Expression Builder is constructing a logical condition (for example, a conditional action).


Expressions can contain literal values, or constants. The following table describes the available literals.

Table 6-8 Literal Values

Literal Type




"string" or `string'

A character string enclosed in single or double quotes. Use the following escape sequences to embed special characters in the string:

\r carriage return character

\n line feed character

\' single quote character

\" double quote character

\f form-feed character

\t tab character

\\ backslash character

\0 ASCII Null character


[+|-] digits

A 32-bit signed integer in the range
-2,147,483,647 to +2,147,483,648 (approximately 9 digits or precision)



A 64-bit IEEE double in the range -253 x 10104 to + 253 x 10104 (approximately 15 digits of precision)


{yyyy/mm/dd hh:nn:ss}

A date and time


An expression can contain references to any workflow variable defined in the associated workflow and to any system-defined variable.

A workflow variable reference can use any one of the following syntaxes:

It is better to use the $ notation for consistency with the XPath function.

The following system-defined variables can be referenced (not updated) in expressions: