65506

how to get the previous task name in activiti workflow

Actually i want to use the previous task name in current task so how to get the previous task name in current task in activiti. If any one knows could you help me?

eg:TASK1==>TASK2==>TASK3

i want to use the task1 name in task2 and task2 name in task1.

Answer1:

You can get it from your current Process Instance:

@Service public class SomeWorkflowService { @Autowired HistoryService historyService; @Autowired TaskService taskService; public Map<String, Object> currentTaskService(String currentTaskId) { Map<String, Object> taskMap = new HashMap<>(); Task currentTask = taskService.createTaskQuery().taskId(currentTaskId).singleResult(); HistoricTaskInstance previousTask = findPreviousTask(currentTask.getProcessInstanceId()); taskMap.put("Current task name: ", currentTask.getName()); taskMap.put("Previous task name: ", previousTask.getName()); return taskMap; } // Order tasks by end date and get the latest public HistoricTaskInstance findPreviousTask(String processInstanceId) { return historyService.createHistoricTaskInstanceQuery(). processInstanceId(processInstanceId).orderByHistoricTaskInstanceEndTime().desc().list().get(0); } }

There maybe some issues with this kind of simple algorithm. For example, I have multiple subprocesses in application, or there may be parallely executed tasks, then I'm using more complex algorithm to find previous task.

Recommend

  • How to pass argument while calling Task Scheduler from c#
  • Spring:xml config convert to java config
  • How to clear out the contents of a map when clear() method call throws UnsupportedOperationException
  • Update Search Results to Lazy Adapter in android
  • How to apply async task into this
  • ThreadPool behaviour: not growing from minimum size
  • Error building image: Error building rlang - not available on R 3.5.0 (Uploading shiny)
  • How to exclude files in a custom clean task?
  • Ant: fileset “dir” attribute with a runtime expanded full path
  • Rails 3, Custom Actions, and HTML request methods
  • Picasso Taking time to load images
  • get all processes in parallel
  • How to override __call__ in celery on main?
  • Get the last date of each month in a list of dates in Python
  • Main Thread Checker: UI API called on a background thread iOS 11 Xcode 9 GM Seed
  • Activation Function choice for Neural network
  • How can I replace the server in Web Component Tester
  • converting text file into xml using php?
  • Unable to get column index with table.getColumn method using custom table Model
  • custom UITableViewCell with image for highlighting
  • How to add a column to a Pandas dataframe made of arrays of the n-preceding values of another column
  • script to move all files from one location to another location
  • AT Commands to Send SMS not working in Windows 8.1
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Rails 2: use form_for to build a form covering multiple objects of the same class
  • JTable with a ScrollPane misbehaving
  • How do I configure my settings file to work with unit tests?
  • How does Linux kernel interrupt the application?
  • apache spark aggregate function using min value
  • Is it possible to post an object from jquery to bottle.py?
  • unknown Exception android
  • Running Map reduces the dimensions of the matrices
  • Sorting a 2D array using the second column C++
  • costura.fody for a dll that references another dll
  • Observable and ngFor in Angular 2
  • failed to connect to specific WiFi in android programmatically
  • UserPrincipal.Current returns apppool on IIS
  • Android Heatmap on canvas or ImageView
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?