SpiffWorkflow icon indicating copy to clipboard operation
SpiffWorkflow copied to clipboard

How to use completionCondition in multi-Instance ?

Open kadyang opened this issue 3 years ago • 5 comments

is SpiffWorkflow support completion condition ?

example case : if 3/5 member approve, then go to next step.

I already try some setting but still need to complete all multi-Instance task ...

kadyang avatar Jul 21 '22 15:07 kadyang

there is an internal variable, and it's definition is like "Activity_1sq1srn_CurrentVar". you should replace "Activity_1sq1srn" with your activity identifier. this variable will be updated(+1) when one of the tasks which been created by multi-instance gets completed

agui001 avatar Jul 22 '22 04:07 agui001

I will get you some additional details on completion condition in a moment. However, I would recommend that you use Lanes when modelling an approval process, as it will solve many issues that you won't be able to address well with just a Multi-instance task. Something like this: image

danfunk avatar Jul 22 '22 20:07 danfunk

To respond to your specific question, the answer is No, not currently. Presently a Multi Instance task is designed to handle iterating over a predefined list of objects, or doing something a specific number of times. You can think of Multi-Instance in SpiffWorkflow as a "For Each" loop rather than a "Do While" loop, it is intended to handle the case of looping over a known set of objects.

I would tend to handle a "Do While" instance like this: image

Some of the confusion here stems from using Camunda's properties panel with SpiffWorkflow. Camunda is a wonderful group that built the open source BPMN.io, and provides an excellent free bpmn editor. But we won't ever be 100% compatible with them. That is why we are using the BPMN.io framework to create our own BPMN Properties Panel -- the early beginning of which is available here: https://github.com/sartography/bpmn-js-spiffworkflow. It isn't ready for use right away. I just want you to understand we are working like hell.

danfunk avatar Jul 22 '22 20:07 danfunk

I know i can make a loop by task and gateway to resolve the case like sequential multi-instance. but if my case is parallel multi-instance, and the loop cardinality is not fixed (decide by vars) i don't know how to resolve it by exist element i can use in spiffWorkflow. 😢

kadyang avatar Jul 25 '22 08:07 kadyang

@kadyang - MultiInstance is a good shorthand way to describe a loop, bit you don't have to use it to solve any specific problem. I am the first to admit that our Multi-instance code is in need of a refactor. I just have to find the funding to make it happen (and if you would like to help fund that effort, we should talk!). In the mean time, i would solve your problem using a loop, as I provided in that first response. If you feel this will overcomplicate the top level workflow, use a Call Activity or Collapsed Sub-Process to hide the complexity. What I definitely would NOT do, is hide a Collaboration within a MultiIstance. You definitely want to use lanes in that circumstance.

danfunk avatar Jul 25 '22 15:07 danfunk