Sun Worklist Manager Service Engine User's Guide

Using XPath Expressions and Functions in Task Definitions

You can use XPath expressions to dynamically derive the values for user names, notifications, escalations, and other properties of a task definition. Two internal variables are provided: TaskInput and TaskOutput. TaskInput is read-only and holds a single element of the input message from the workflow process that triggers the task instance. These are the values that are used to populate the task definition properties. TaskOutput holds the output message that is returned to the workflow process when the task completes. Initially it is an empty element.

TaskInput and TaskOutput are single-part variables. The Task Definition Editor provides a mapper that allows you to graphically define XPath expressions for initialization and changing these variables on the Actions tab. For the General, Escalations, and Notification tab, you can type the expressions manually. An XPath expression in the Task Definition Editor begins with an equals sign (=), which is stripped out in the actual source code.

About WLM XPath Functions

The WLM SE provides functions to retrieve information from the Worklist Manager database about task owners, email addresses, and LDAP UIDs. You can enter the functions directly into the task definition file using the syntax described below, or you can use the task mapper to graphically add the functions to the file. The mapper is described in Using the Task Mapper.

Standard Functions

Currently the WLM SE provides one function that retrieves the owner of a particular task.

wlmfn:get-task-owner as xs:string

This function returns the user who claims the task. If the task is not claimed, it returns null.TaskInstance.Owner is automatically assigned by the WLM SE when a user claims the task.

LDAP Functions

LDAP functions are only available when LDAP is used for task assignment and authorization. The namespace for these functions is http://jbi.com.sun/wfse/xpath-functions.

wlmfn:get-email() as xs:string

This function retrieves the email address for the user who claimed the task.

wlmfn:get-email($arg as xs:string) as xs:string

This function retrieves the email address for the user specified in the argument passed to the function.

wlmfn:get-manager-email() as xs:string

This function retrieves the email address for the manager of the user who claimed the task.

wlmfn:get-manager-email($arg as xs:string) as xs:string

This function retrieves the email address for the manager of the user specified in the argument passed to the function.

wlmfn:get-manager–uid() as xs:string

This function retrieves the LDAP UID for the manager of the user who claimed the task.

wlmfn:get-manager–uid($arg as xs:string) as xs:string

This function retrieves the LDAP UID for the manager of the user specified in the argument passed to the function.

Initializing Variables

Initializing a variable allows you to define some default value for the task output when a user views the task on the Worklist Manager Console. Variables are initialized using the init element of the task definition file. This is not a required section for the file. Variable initialization occurs before the task is created, and once the variable is assigned it cannot be changed. If you define the initialization using the Task Definition Editor Mapper, it automatically writes this section for you.

The format of the init element is as follows:


<init>
   <variables>
      ...
   </variables>
   <variable-init>
      <copy>
         <from>XPath_or_literal</from>
         <to>XPath_variable</to>
      </copy>
   </variable-init>

For example, this excerpt from the sample project maps the literal value “Approved” to the approveResult:


<variable-init>
      <copy>
         <from>'Approved'</from>
         <to>$TaskOutput.part1/ns:approveResult</to>
      </copy>
   </variable-init>

For an example of how this is implemented in the Mapper, see Initializing Variables Using the Mapper.

Entering XPath Variables in Design View

When you enter XPath expressions directly into the graphical Design view of the Task Definition Editor, you begin the expression with an equals sign (=) to let the editor know that the value is a variable and not a literal value. The equals sign is not part of the generated XPath in the source code.

For example, the variables in the figure below translate into the following source code in the task definition file:

Figure shows variables as XPath expressions on
the Task Definition Editor.