Activiti gets the exit of the current activity (task) (dynamic generation and submission button), activiti current
1. Set exit Variables
When a task has one or more exits, you can set judgment conditions on the egress links.
2. Obtain the export set based on the task Id.
Public List <String> getOutGoingTransNames (String taskId) {List <String> transNames = new ArrayList <> (); // 1. obtain the process definition Task = this. taskService. createTaskQuery (). taskId (taskId ). singleResult (); ProcessDefinitionEntity pd = (ProcessDefinitionEntity) repositoryService. getProcessDefinition (task. getProcessDefinitionId (); // 2. obtain the process instance ProcessInstance pi = runtimeService. createProcessInstanceQuery (). processInstanceId (task. getProcessInstanceId ()). singleResult (); // 3. find the ID String activitiId = pi of the current activity through the process instance. getActivityId (); // 4. activity ID is used to find the activity object ActivityImpl activity = pd in the process definition. findActivity (activitiId); // 5. use the activity object to find all the exits of the current activity List <PvmTransition> transitions = activity. getOutgoingTransitions (); // 6. extract the names of all exits and encapsulate them into a set for (PvmTransition trans: transitions) {String transName = (String) trans. getProperty ("name"); if (StringUtils. isNotBlank (transName) {transNames. add (transName) ;}} if (transNames. size () = 0) {transNames. add ("Submit"); // default} return transNames ;}
3. Applications
When the page is displayed, traverse the node exit and input the corresponding commit exit name when submitting
Code submission:
Map <String, Object> vars = new HashMap <> (); vars. put ("outcome", outcome); // outcome is the name of the submit button.
// Complete the task
TaskService. complete (taskId, vars );