Reassigning a task to a new group

In IBM® Business Automation Workflow, there are REST APIs and JavaScript APIs that enable you to assign a task to a new group.

About this task

You can reassign a task to a user, group, or team using REST APIs or JavaScript APIs. When a group or team is updated, the associated manager team is also updated. If you assign a task to a team, the team must exist in the snapshot scope that is currently associated with the task.

If you are considering reassigning a task to a group, it is generally recommended that you reassign the task to a team from the task's current snapshot context.

Note:

If a task is reassigned to a group that is associated with a different snapshot than the task, it can cause problems for snapshot deletion. The instructions in this help topic can be used to replace an ad hoc group that might be blocking snapshot deletion.

If a task is reassigned to a group that does not have a manager team, the task's manager team will be cleared. Prior to IBM Business Automation Workflow V20.x, the assigned manager team is only changed when the task is reassigned to a group that has a manager team.

Procedure

To reassign a task to a new team:

  1. Select one of the following approaches:

    • If you want to reassign a task to a new team by using REST APIs, build a client application or use the REST API test tool to perform the required operations. For information about using the REST API test tool, see Testing the IBM BPM REST APIs. You can review the teams for a snapshot by using Process Designer or the Install Apps tab of the Process Admin Console. The steps that you would follow to reassign a task to a new team by using REST APIs differs depending on the version of IBM Business Automation Workflow:

      •  20.0.0.2 In IBM Business Automation Workflow V20.0.0.2 and later, use the Task Instance resource PUT (assign task) method to assign the task to the new team. You should pass the name using the toTeam parameter. For example:
        PUT /rest/bpm/wle/v1/task/1234?action=assign&toTeam=HiringManagers&parts=all
        For more information, see REST interface for BPD-related resources - Task Instance Resource - PUT (assign task) Method.

      • In IBM Business Automation Workflow V20.0.0.1 and earlier, complete the following steps:

        1. To obtain detailed information about a task, such as its current snapshot context, use the Task Instance resource GET method that is described in the topic REST interface for BPD-related resources - Task Instance Resource - GET Method.

        2. Obtain the internal team name by running the following SQL query (where 'team_name' is the name of the team that you want to use and 'snapshot_id' is the snapshot ID from the current task context):
          Select g.group_name from LSW_USR_GRP_XREF g, LSW_PARTICIPANT_GROUP t Where g.group_id = t.group_id AND g.display_name = 'team_name' AND t.snapshot_id = 'snapshot_id'

          The snapshot ID is the GUID that follows '2064.' in the task details.

        3. Use the Task Instance resource PUT (assign task) method to assign the task to the new team. You should pass the name using the toGroup parameter. For example:
          PUT /rest/bpm/wle/v1/task/1234?action=assign&toGroup=HiringManagers_S_cd97937f-06ab-43cc-8067-17dea489fdb3.481abfd8-9868-4638-ace0-7932d46958d5&parts=all

          For more information, see REST interface for BPD-related resources - Task Instance Resource - PUT (assign task) Method.

    • If you want to reassign a task to a new team by using JavaScript APIs, build a service that is able to run the required JavaScript API methods. The following example shows how task 1234 is reassigned to the team MyNewTeam:
      var task = tw.system.findTaskByID(1234);
      task.reassignTo(task.processInstance.snapshot.findParticipantGroupByName("MyNewTeam").associatedRole);

      For detailed information about the JavaScript APIs, see JavaScript API in processes and service flows.

  2. Confirm that the task is now reassigned to the specified team.