During the lifetime of an activity instance or a task instance,
the set of people associated with the object can change, for example, because
a person is on vacation, new people are hired, or the workload needs to be
distributed differently. To allow for these changes, you can develop applications
to create, delete, or transfer work items.
Why and when to perform this task
A work item represents the assignment of an object to a user or
group of users for a particular reason. The object is typically a staff activity
instance, a process instance, or a human task. The reasons are derived from
the role that the user has for an activity or task. An activity or task can
have multiple work items because a user can have different roles in association
with the activity or task, and a work item is created for each of these roles.
The
actions that can be taken to manage work items depend on the role that the
user has, for example, an administrator can create, delete and transfer work
items, but the task owner can transfer work items only.
Steps for this task
- Create a work item.
// query the task instance for which an additional
// administrator is to be specified
QueryResultSet result = task.query("TASK.TKIID",
"TASK.NAME='CustomerOrder'",
(String)null, (Integer)null,
(TimeZone)null);
if ( result.size() > 0 )
{
result.first();
// create the work item
task.createWorkItem((TKIID)(result.getOID(1)),
WorkItem.REASON_ADMINISTRATOR,"Smith");
}
This action creates a work item for the
user Smith who has the administrator role.
- Delete a work item.
// query the task instance for which a work item is to be deleted
QueryResultSet result = task.query("TASK.TKIID",
"TASK.NAME='CustomerOrder'",
(String)null, (Integer)null,
(TimeZone)null);
if ( result.size() > 0 )
{
result.first();
// delete the work item
task.deleteWorkItem((TKIID)(result.getOID(1)),
WorkItem.REASON_READER,"Smith");
}
This action deletes the work item for the
user Smith who has the reader role.
- Transfer a work item.
// query the task that is to be rescheduled
QueryResultSet result =
task.query("DISTINCT TASK.TKIID",
"TASK.NAME='CustomerOrder' AND
TASK.STATE=TASK.STATE.STATE_READY AND
WORK_ITEM.REASON=WORK_ITEM.REASON.REASON_POTENTIAL_OWNER AND
WORK_ITEM.OWNER_ID='Miller'",
(String)null, (Integer)null, (TimeZone)null);
if ( result.size() > 0 )
{
result.first();
// transfer the work item from user Miller to user Smith
// so that Smith can work on the task
task.transferWorkItem((TKIID)(result.getOID(1)),
WorkItem.REASON_POTENTIAL_OWNER,"Miller","Smith");
}
This action transfers the work item to
the user Smith so that he can work on it.