How do you set the approver for the next node in Activiti?
In Activiti, setting the approver for the next node typically involves defining a process variable in the process definition file to store the approver information, and then dynamically setting the approver in the process instance. Here is a basic example:
- Define a user task node in the process definition file, for example:
<userTask id="userTask1" name="审批任务" activiti:assignee="${approver}" />
- When starting the process instance, set the value of the process variable “approver” to the user ID of the approver, for example:
Map<String, Object> variables = new HashMap<>();
variables.put("approver", "john.doe");
runtimeService.startProcessInstanceByKey("processKey", variables);
- When the process reaches the user task node, the process engine will assign an approver to that node based on the value of the “approver” in the process variables.
Please note that the way in which approvers are set can be adjusted based on specific business needs and implementation methods. The above is just a basic operation example. You can further customize and optimize the process definition and process variable settings according to the actual situation.