Camunda with Spring Boot REST API

Hi,

I am new to Camunda workflow. I am integrating camunda workflow engine with spring boot REST application.

I got my request process initiated by these lines in my controller api…
Suppose john has initiated.

Map<String, Object> variables = new HashMap<String,Object>();
variables.put(“requestInitiator”, “john”);
ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey(“requestFlow”, variables);

  1. I am using requestInitiator variable in my task assigne and it is getting stored in table ACT_RU_TASK table with assignee column value as john. Is this right approach/way to do it???

  2. How do I get all tasks assigned to a particular user??? Do I have to fetch like this
    List tasks = taskService.createTaskQuery().taskAssignee(“kermit”).list();

  3. Now on clicking from the above tasklist I will display respective fields from our table. Once he approves, I want to pass/delegate the task created to some other user… how do i achieve that. I read the docs and it has
    delegateTask.setAssignee(“admin”);
    but I dont get how do i get taskid…to which specific task i want to delegate in other controller.

Can anyone please guide me or share a code snippet that could help me in understanding better…
Awaiting for a response

Thanks,
Amit

Hi Amit,

You are on the right track on the first two points. However I don’t get what do you want to achieve in the third point:

You want to pass the current task to another user or the question is for assigning the next task…?
Maybe it would be easier to share with us example of your process in order to visualize the question.

Best regards,
Yana

Thank you so much for the reply and confirmation about first 2 points I had raised.

I am using angular 4 in front end and forms are created using smartadmin. Once the form is submitted I initiate a workflow request and store form fields in our table. Now the submitted form has to go for an approval by upper management.

So my question is

  1. How do I map my request form table with task table??? Shall I store a taskId generated while initiating a request i.e., ID_ from ACT_RU_TASK in our request table ??? or there is an another better approach may be ???
  2. when the Higher authority approves the submitted request, how do I delegate the task to other user??? I have tried taskService.delegateTask(taskId, user);
    So on every department approval I will have to delegateTask like this ???
  3. How can I get activities performed by different users on a task ??? I would want to show the current status along with activity’s progress ??

Please guide me through this…

Hello Amit,

It is hard to understand what is your goal.

Here what you can do from the backend:

  1. Set owner to the task
    taskService.setOwner(taskId, kermit)
  2. Delegate task to another user piggy
    taskService.delegateTask(taskId, piggy) -> the assignee becomes piggy
  3. The assignee/piggy must resolve the task
    taskService.resolveTask(taskId)
  4. Only the owner/kermit can complete the task
    taskService.complete(taskId)

Does this help you?

Best regards,
Yana

Yes this is quite helpful really.

  1. Once the delegated task is resolved is it assigned to owner to set the task complete ???

  2. Actually in my ACT_RU_TASK table owner is getting stored as null so whenever this delegation is to take place owner has to be set before delegation. RIGHT ???

Thank you for the help…Lot of things getting clear now…

Hi again,

Yes, you are right.

  1. After the resolving, the task is reassigned to the owner so they can complete it.
  2. Right, the owner should be set before the delegation. If no owner is set on the task, the owner is set to the current assignee of the task which is not useful in your case (I think).

Best regards,
Yana

Thank you so much yana for such clear explanations…It was quite helpful…