caluma icon indicating copy to clipboard operation
caluma copied to clipboard

prev_work_item does not resolve as expected in dynamic tasks

Open StephanH90 opened this issue 8 months ago • 0 comments

When you have multiple dynamic tasks after a task/flow like this:

{
    "model": "caluma_workflow.task",
    "pk": "my-regular-task",
    "fields": {
      "type": "complete_task_form",
      "form": "a-form"
    }
  },
{
    "model": "caluma_workflow.taskflow",
    "pk": "...",
    "fields": {
      "task": "my-regular-task"
    }
  },
{
    "model": "caluma_workflow.flow",
    "pk": "some pk",
    "fields": {
      "next": "['my-first-dynamic-task', 'my-second-dynamic-task']|tasks"
    }
  },

and you have these dynamic tasks:

@register_dynamic_task("my-first-dynamic-task")
    def resolve_dynamic_task_1(self, case, user, prev_work_item, context):
        # here prev_work_item refers to the "my-regular-task" work item

@register_dynamic_task("my-second-dynamic-task")
    def resolve_dynamic_task_2(self, case, user, prev_work_item, context):
        # here prev_work_item refers to the "my-first-dynamic-task" work item  <<<<------ is this intended?

For me, this seems counterintuitive. I wouldn't expect the order of the tasks in the next to matter, since they are being opened in parallel anyway. I would assume that prev_work_item should in both cases refer to the work item that belongs to the my-regular-task.

StephanH90 avatar Jun 26 '24 08:06 StephanH90