How to get Task IDs for a specific process instance or by passing various fields in JBoss BPM Suite 6?

Solution Verified - Updated -

Environment

  • Red Hat JBoss BPM Suite (BPMS) 6.x

Issue

  • How to obtain Task IDs for a particular process instance?
  • How to obtain tasks by passing various fields (i.e. status and potential owners)?

Resolution

There are the following options how to achieve this.

  • Task Service API
    TaskService API can be used in embedded mode but also when obtained from RemoteRuntimeEngine. In order to achieve that you can use:

    List<Long> procInstIds = new ArrayList<Long>();                     
    procInstIds.add(piid);
    List<String> potOwners = new ArrayList<String>();                     
    potOwners.add("john");
    List<Status> status = new ArrayList<Status>();                     
    status.add(Status.Created);
    status.add(Status.Ready);
    status.add(Status.Reserved);
    status.add(Status.InProgress);
    status.add(Status.Suspended);
    List<String> languages = new ArrayList<String>();                     
    potOwners.add("en-UK");
    
    List<TaskSummary> list = taskService.getTasksByVariousFields(
                        null, null, procInstIds, null, potOwners, null, status, languages, false);
    
  • Through Rest API

/rest/task/query?processInstanceId=pid
  • Using the Query API. Starting on BPM Suite 6.1, a new Query API is available and it allows tasks query using various fields and also using regex expression.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments