Replacement variables: Examples of usage patterns in task elements

You can use replacement variables in many different ways. At run time, the values used for the variables can come from many sources. For example, they can originate from previous staff resolutions, custom properties and, in the case of inline tasks, from the surrounding BPEL process.

A task description includes run time-specific information

Use this pattern for client applications that query task descriptions. These descriptions include replacement variables that are initialized when a task is created or started. This pattern requires the following definitions for the task elements in the task template.
Table 1. Task template definitions to include run time-specific information in the task description
Task element Definition
Task custom property

name: 'property1'
value: 'a default value'

Task description

"This task instance has
as ID: %htm:task.instanceID%
as originator: %htm:task.originator%
as administrators: %htm:task.administrators%
as owner: %htm:task.owner%
a custom property with the name 'property1'
which is set to %htm:task.property.property1%

If you use the setCustomProperty method on a task instance, you can set an individual custom property for the task instance. When the task starts, the task description is evaluated, and this value is included in the description that is displayed in the client application.

Control the duration of task with a custom property

Use this pattern so that a client application can control the duration of a task instance. This pattern requires the following definitions for the task elements in the task template.
Table 2. Task template definitions to control the duration of a task
Task element Definition
Task calendar 'Simple'
Task custom property

name: 'property1'
value: '2days 3hours'

Duration until overdue %htm:task.property.property1%

If you use the setCustomProperty method on a task instance, you can set a custom property for the task instance in a format that is allowed by the simple calendar. When the task starts, the duration until overdue is evaluated, and this value is inserted for the duration.

Control the people assignment of an inline task

Use this pattern to control the people assignment for a task instance based on the people assignment for a previous task in the BPEL process. This pattern requires the following definitions for task elements in the task template.
Table 3. Task template definitions to control the people assignment of an inline task
Task element Definition
People assignment for potential owners role Users by User ID

userId: %wf:activity(activity1).owner%

In the replacement variable, activity1 is a human task activity in a BPEL process that is in the claimed state. This means that the owner of the task is known. When the second task is started, the people assignment for the potential owners is evaluated. The owner of the first task is inserted as the parameter value in the people assignment expression.

Expose part of an input message as a custom property

Use this pattern to expose part of an input message for queries on tasks. You can use a custom property to refer to the part of the input message that you need, and then use this property for querying, sorting, or filtering tasks. The custom property can be a user-defined custom property, or one of the predefined inline custom properties. Use an inline custom property with a query table to improve the performance of the task query. Because the attribute that corresponds to the inline custom property is stored in the same query table as the task, sorting and filtering are more efficient.
Table 4. Task template definitions for exposing part of an input message
Task element Definition
Task custom property

name: customerId
value: "%htm:input.\customerId%"

Task inline custom property

name: CUSTOM_TEXT1
value: "%htm:input.\customerId%"

For example, a task is started with an input message that contains the customer ID 0815. To sort the query results to find this task, you can define an inline custom property, CUSTOM_TEXT1, and then define sort criteria in the query table for this attribute.