Automatic Put-Back Action for BPM Tasks
We have developed several BPM processes with tasks that have multiple potential task owners. What would regularly happen is that one task owner would open the task, but not work on it and just close the task browser window. The task is now reserved (claimed) for that owner. The other potential task owners no longer could see the task in their work list. That led to tasks that are not being worked on, potentially for a long time.
This caused some unpleasant user comments about the process. Since SAP BPM doesn’t offer an automatic Put Back out of the box, we decided to implement our own solution to this problem.
To implement an automatic Put Back we did the following:
- Designed a Cancel option in the process model (only needed with SAP BPM < 7.31)
- Added Cancel as task decision option
- Detected a browser close using Web Dynpro wdDoExit hook method and then completed the task with cancel decision
We also implemented an additional functionality we call Save & Close. This allows the user to work on the task, e.g. enter data and comments, and then put the task back in the pool of the potential task owners.
In the next sections I will explain in detail how to implement the solution.
For each human task the user’s decision is evaluated by an exclusive gateway. If the decision was Cancel or Save & Close the process goes back to that human task. With Save & Close the input of the user will be saved.
If you use task email notification via SAP BPM (global or task specific), all potential users are notified again. In some processes we use custom E-Mail notification which is handled in an automated task just before the human task. In this case no additional email is sent. This is usually the desired behavior with our users.
Also consider that for each Save & Close or Cancel a new task instance is created. Depending on the size of the process context and number of instances, this might increase database storage needs significantly.
With 7.31 the task can be put back using the BPM API which does not create a new task instance. This also means that no email will be send from the process. You could still trigger emails from the Web Dynpro application if needed.
In the Web Dynpro layer there is quite a bit more to do.
First we need to get the taskId which is posted to the Task UI from the UWL and store it in the session. We do this in the wdDoInit hook method.
We also need a couple other variables which are declared in the Others section.
When the user clicks on the decision buttons in task view, the corresponding method in the Component Controller is called. For example the Save & Close and Cancel decision:
Next in our processes we show a Confirmation dialog. When the user clicks OK in the dialog we handle the result in the event handling method for this dialog.
Here you can see how the Save & Close decision is handled. It is very important here to set the variable completed to true. We use this variable later on in the wdDoExit method to decide if the exit happened because of a regular task completed event or a browser close event.
The Cancel decision simple sets the according decision in the Web Dynpro context and fires the task complete event.
For all other decisions we are saving the data entered by the user, writing a history entry in our process log, setting the corresponding decision to be passed back to the process context and firing the task completed event.
Next we take a look at the wdDoExit hook method. Here we handle the browser close event.
If the task wasn’t completed by a user’s decision, we can assume the user simple closed browser. In this case we use the BPM API to get the task instance. This is needed because the wdDoExit is always called by the Web Dynpro Framework.
Using SDO we pass the correlation ID and the decision back to the process. Then we complete the task. This will cause the process to continue with the next step. Because we set the decision to Cancel, the process goes back to the task. This again is modeled in the process model.
With 7.31 you would put back the task using the BPM API instead of completing the task.
To use the BPM API in the Web Dynpro Task UI, the dependencies need to be configured accordingly. You have to add the following required DC’s: