Designer 10.5 | webMethods BPM Task Development Help | Working with Task Expressions | About Expression Managed Beans
 
About Expression Managed Beans
When a condition or action expression is evaluated, the Task Engine creates and makes available specialized managed beans. You can also create custom objects for use with expressions as long as they are defined as managed beans in the task application (just as you would when using binding expressions in a CAF application).
For example, additional beans are used when a task action publishes a notification or uses a business calendar to evaluate date/times; these beans are usually auto-generated when the corresponding data element or action is specified in the task expression editor. It is also possible to manually define them as managed beans in the application and use them in the rule expressions.
Following are managed beans that are automatically defined when evaluating expressions:
*#{currentTask}—this is an instance of the specific TaskContentProvider class for the task being assigned. That is, it is the same class that is used in the task details portlet. Any property of TaskInfo and TaskBusinessData or any action can be accessed from it using the same binding expressions used on a task details portlet when rooted from #{currentTask}.
*#{currentUser}—identifies the current user on behalf of whom these expressions are being evaluated. #{currentUser} is only available when a request originates from a user; for example, it is not available for task events, which are processed in the background. #{currentUser} is contained in the class com.webmethods.caf.faces.data.dir.UserModel, which provides access to basic and advanced attributes of a user object
Some examples of property binding expressions:
*#{currentTask.taskInfo.name}—name of the current task.
*#{currentTask.taskInfo.assignedToList}—list of principals to whom the task is assigned.
*#{currentTask.taskData.order.orderNumber}— the order number from a business data order document attached to the task.
Some examples of action binding expressions:
*#{currentTask.completeTask}—completes a task (though it does not make sense to complete a task from assignment)
*#{currentTask.applyChangesNoAccept}—updates the task instance by applying any changes specified to TaskInfo and TaskBusinessData
*#{currentGroup}—an instance of PortalUserModel that represents the group principal to which task is to be assigned. This can be used to obtain group-specific attributes to define assignment conditions.
*#{currentRole}—an instance of PortalGroupModel that represents the role principal to which task is to be assigned. This can be used to obtain role-specific attributes to define assignment conditions.
*#{currentUser}—an instance of PortalRoleModel that represents the user principal to which task is to be assigned. This can be used to obtain user-specific attributes to define assignment conditions.
*#{<TaskName>RuleContext}—This context object is always available for task rules expression evaluation (for both assignments and events). This is an object which is exposed in the bindings view under "Services" and which is usually used to expose custom actions/properties (like web service connectors) for task rules
Expressions For Task Events
In addition to #{currentTask}, the Task Engine also exposes #{oldTask} and #{newTask} objects; these simply represent the task state before and after a task update. Having these is useful when an event is to be triggered upon some specific modification. For example, the following is a condition for Queued event:
(#{oldTask.taskInfo.status} == "new") && (#{newTask.taskInfo.status} ==
"active")
This expression detects the change of status field from "new" to "active".
The #{currentUser} object is not available for task events.
Any update actions applied to a task can be executed only against a #{currentTask} object, but not against #{oldTask} or #{newTask}; the latter are essentially read-only containers of data.
For example, the following action expression updates the name of the task and some task business data, followed by an action to apply the changes.
#{currentTask.taskInfo.name} = #{currentTask.taskData.order.orderNumber};
#{currentTask.taskData.orderValue} = (#{currentTask.taskData.orderValue} * 100)
+ 10;
#{currentTask.applyChangesNoAccept};
Related Topics