How to start BPM process with immediate opening of the first human activity for the initiator.
In some cases is necessary to open the first human activity step for initiator immediately after the start of the BPM process.
The simple realization of this behavior for initiator in portal consists of the following steps:
- Initiator starting BPM process in portal application with a minimum set of attributes passed to the bpm process via web-service.
- Navigating to UWL or BPM Inbox.
- Check the list of tasks for any new task.
- If some new tasks is coming, initiator try to recognize one of the task that need to be open immediately and fill all data in UI.
- If the task was found, the initiator need to open it and start working.
But often, users don’t want spend the time for performing steps 2,3,4 and go to the step 5.
In view of this requirement, the scenario of user behavior on the portal already consists of two steps:
- Initiator starting bpm-process in portal application.
- After starting of bpm process, the first human activity step opens in different window for initiator.
In this post, I would like to show how you could implement this scenario for opening human activity step for initiator after start of bpm-process without any switching between portal applications.
The scheme of this approach consists of the following steps:
- Run the bpm-process and sending the minimum set of attributes in the bpm-process context.
- In standby mode (a few seconds) check, that the new task is coming in the list of bpm tasks assigned to the initiator.
- Open the task in a separate window.
For this scenario, we need some unique identifier. For example, the request number. We need to get or generate this unique Id before the start of the process and to transfer the value of this attribute in the input parameters of the task of human-activity.
We transfer this Id in the process context, save it in the Data object of BPM process. Then we pass value of Id attribute in the subject of the task. This becomes possible only if the Id parameter passed in input parameter of the task object.The addition a unique identifier in the Subject the task performed in the User Texts settings.
Next, we need to implement some methods in the application, which is using to start of BPM processes.
Code for this method might look like this:
The code of startProcess, searchTaskByRNumber, openTaskByUrl you can see below.
Therefore, the main idea is in search of task by unique value in subject of task. You can search tasks with unique attribute in data objects of task. However, using the data objects we can have the problem with large Java resource costs.
I hope the information will be useful for you, in case when you need to open human activity step immediately after the start of BPM process.