When working on tasks in BPM users often do not complete their work in a single session. Instead, they will open their task, enter some data on the page and then close their task to resume work at a later point. Users may or may not properly close their task by pressing a dedicated button, or they may click on another link in the Process Portal, or open a new link in the current browser tab, or even simply close the tab or the entire browser altogether. This raises a number of questions and this article discusses a simple pattern for handling the saving and closing of unfinished tasks in IBM BPM.
The idea is to provide a “Save & Close” button that users can press when they want to save the current progress of their task and return to the work list. Of course, you could implement variations of this by providing separate “Save” and “Close” buttons where “Save” would not close the task and “Close” would work the way as the “Save & Close” described here.
First, let’s take a look at the diagram for the Heritage Human Service.
We will use a Boolean variable
resumeAfterPostpone that is set to
true after the Postpone step. In the On Load step this variable is reset to
false and the Boolean variable
showWarningMessage is set depending on whether the task was resumed from postpone or not.
tw.local.resumeAfterPostpone = true; tw.local.showWarningMessage = false;
tw.local.showWarningMessage = !tw.local.resumeAfterPostpone; tw.local.resumeAfterPostpone = false;
So how does this “On Load” event work? The Coach contains a Coach View “Trigger on Load” that fires a boundary event during its View event. So every time the Coach is generated – be it the first time the task is opened or any subsequent access to the task – the event is fired and the “On Load” script is executed.
For this simple example the Coach consists of a section which contains a Custom HTML element with the warning message to be shown if the user closed their task in any other way than pressing the “Save & Close” button.
Displaying the message is controlled through a Visibility rule based on the
Now, if you open the task and did not use “Save & Close” last time, the text box is shown:
The above solution obviously does not prevent users from closing the tab or browser anyway. However, implementing an event handler for the window’s onbeforeunload, which is the usual (annoying!) way of preventing users from leaving your site is not really an option for BPM coaches. You have to handle both cases: 1) the Human Service is openend alone and 2) the Human Service is opened in the iframe of the Process Portal. The event does not work with boundary events that have already been sent off. The implementation described here is a compromise between technical feasability and educating users how to use the system.