I have a simple Purchase Order workflow with multiple approvals I am trying to understand how to make the integration between my application and camunda in the right way. I am documenting my current understanding based on docs and other forum posts. I have modelled the flow as shown in the image.
From what I understand, I need to setup a service in front of every user task so that the corresponding notification is synced to my application db, e.g. If the “accountant should be allowed to approve” check is Yes, then I need to place a service block just before Accountant Approval user task. This service should fetch the task id somehow (using
/engine-rest/task?processInstanceId=... endpoint?), and add an entry in the application “notification” table with that task ID. This will ensure that the user gets the notification in my app. When the user views the notification and approves, this would need to trigger an API call to
The new model would look like this
Is this the recommended way?
Now I was trying this model, and used a NodeJS service to handle the “Notify” task. I would need to capture the next task id (General Manager Approval) to be able to assign the task to the user in my application database. Only then would I be able to execute the API call to mark the task as completed.
Is there any way to solve this using this design, or should there be another design?
Heres an alternate way to think about it. I tend to try an keep implementation details such as your notify service tasks out of the process model. Rationale - I want the process model to reflect the business process without the implementation detail.
However, you are correct that to implement an executable model, there must be some implementation detail somewhere. In your case where you want an external client to interact with the user tasks, you could use a task listener to generate and send the notifications. Hence use the task creation event to trigger a handler to send the notification. In addition, all the detail you need such as task Id etc will be readily available…
See task lifecycle here… Refer to task listern here…
@Webcyberrob Thank you so much. That makes sense, and I will give it a try.
@Webcyberrob I have tried to implement this, and have documented what I did here Can we execute external task on task lifecycle events
I am stuck with the implementation in that the conditional event is not being triggered. Please see the link for more details. Thank you for helping out!