Dynamically setting user task assignee

sathishvisa picture sathishvisa · Oct 8, 2013 · Viewed 10.5k times · Source

I have to create process in activiti which requires the following use case.

1.The form has a people search field 2.When someone completes the form and completes the task with a people search field filled with names,I need to set the next task's assigned with the name/names as users who can take action on the next task.

How can I achieve using the activiti engine apis.

any help on this is appreciated.

Thanks in advance.

Answer

ATMTA picture ATMTA · Oct 9, 2013

You can use following steps:

  1. Pass input user value from your html form to Activiti using taskService.complete(task.getId(), taskVariables); taskVariables should contain variable with keys for example 'userId' or 'userIds' to access submitted values in process instance
  2. Use expressions in your process definitions <userTask id="task" name="My Task" activiti:assignee="${userId}"/> or <userTask id="task" name="My Task" activiti:candidateUsers="${userIds}"/> to assign tasks

    Also look to http://www.activiti.org/userguide/#bpmnUserTask and http://www.activiti.org/userguide/#springExpressions for detailed information