Idea Summary
Last week, I was given a task to create a workflow for procurement. I thought it would be a standard workflow but then I faced an issue. See, in this workflow, the process is as follows:
1. Requisition (Choose whatever items you want for the requisition)
2. Send this requisition for approval(Workflow Starts).
3. Then if it is approved, our requisition's status will be changed to ‘Approved’.
4. The next process is consolidated requisition. Now what happens is a user comes in and selects from a list of approved requisitions, and then sends those consolidated requisitions for approval. Now there is the problem.
See, this user can select any combination of requisitions and can send that for approval, so the real problem here is the ‘send that for approval part’. Since this workflow already began, i want, only after the user clicks send for approval, the workflow to flow to the human task for consolidated requisition approval. So what we have to do is basically ‘wait’ for the user to take our requisition put in a consolidated requisition, and then send that for approval. I tried using the wait activity for this, but unfortunately, maybe i am dumb, but it only returns the interval of something, which is not what i want.
What i want is for the wait activity to ‘wait’ until a column's value changes, for eg. to ‘Approval Pending’. Then after that the workflow should continue. So the whole workflow should wait till that approval pending happens for that column. I tried many things, but i finally got a solution to work, its a huge workaround, so hopefully you can find another solution(I explained my solution and the preferred solution in the Preferred Solution down below).
Use Case
It could be used for my use case, and other use cases which i can't think of right now. Um maybe my fellow developers could help.
Preferred Solution
Ok so, my solution that I used is this:
1. Create a human task called ‘Wait’
2. Make every single user a active participant for this human task.
3. After a requisition has been approved it will go here.
4. It will wait how long as we want, as human tasks don't expire unless we set it.
5. On action executed for this wait task, on create, i will insert the task_id into the requisition table for that particular requisition.
6. When a user selects the requisitions needed for the consolidated requisitions, and clicks the send for approval button our wait activity will be “Approved”, using the approve procedure and the task_id from the table for that particular requisition.
7. And thus our workflow will continue from where it left off.
This solution works(i am pretty sure) and has no problems(i am pretty sure). But this is my preferred solution:
In the wait activity itself, instead of only using intervals, make it also work with true/false conditions. Like it checks something in a table and until it returns true, it will wait, for an indefinite amount of time rechecking and rechecking. This would be pretty nice instead of the roundabout way I did. So yeah, thanks for listening, also if any other solution already exists which is easier, please provide below.
Thanks
Emmanuel