1

We know that a subprocess should be started for n items when the task is activated, however, during the lifetime of the NSubprocess task, additional items could be found.

Let's say we have Order and OrderItem. When a customer submits an order and the flow gets to fulfill_orderitems (NSubprocess - FulfillOrderItem flow) task, we start the subprocess for each order item.

However, during the lifetime of this fulfill_orderitems task the customer can contact us to add additional item to the order. At this point we are forced to create a new Order process which is a bit tedioius; whereas if we could simply initiate a new FulfillOrderItem subprocess then things remain much simpler.

Obviously once the fulfill_orderitems is done and the customer calls afterwards to add additional item, then we'd have to either roll back (unpractical) or make a new Order process.

This is just a simple example, but generally speaking this behavior is quite useful. One could argue this should be a core functionality of NSubprocess (ie. to be able to add additional n+1 subprocess during the liftetime of the task). How would one go about doing this?

We need to handle 2 things (from what I can see):

  1. Function that starts this additional process. From what I understand it could be as simple as:
    @Activation.status.transition(source=STATUS.STARTED)
    def start_subprocess(self, item):
        self.flow_task.subflow_task.run(self.task, item)

  1. The view where the item is submitted through a form. Alternatively submit it through code directly. This bit I have trouble coming up with. It should be relatively simple, because it is very similar to what StartSubprocess does... (but we need to call the aforementioned start_subprocess(item)? However, I'm more interested in being able to call the method directly (eg through DRF).
emihir0
  • 1,200
  • 3
  • 16
  • 39
  • This seems easily can be achieved by implementing custom node subclass. – kmmbvnr Jan 30 '20 at 07:51
  • @kmmbvnr Yes it should be simple, but there is so few examples available that I have trouble coming up with it (node & view). Perhaps add some more examples of custom nodes/gates/views to your docs and/or cookbook? – emihir0 Jan 30 '20 at 13:41

0 Answers0