cancel
Showing results for 
Search instead for 
Did you mean: 

How to re-create the path a workflow took?

roadtripryan
Champ in-the-making
Champ in-the-making
I need to re-create a processes and the steps before the current step to get the username of who completed the step previous to the current (service) task.

In particular, I don't see where service tasks are in the history tables, or how to find which execution called a current execution.

Any tips on re-creating the path a workflow took?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
That info should be stored in the ACT_HI_ACTINST table, accessible through the historyService query api.

roadtripryan
Champ in-the-making
Champ in-the-making
I feel like I must be over complicating this. All I need is the user that did the task that led to this service call.

Example diagram attached shows any of 3 user tasks could led to Service Task 2, and I want to know which user led to Service Task 2 being call during any given call to user task 2.

Does this seem like the correct approach?

#1) Get the model, and iterate through it to find which tasks can lead to this service (for service 2 in my example, this would be User A, User B, or User C tasks)
#2) Iterate through the HistoricActivityInstance in reverse order. I assume the first entry is the activity that led to this web service.
#3)  If the most recent entry is a user task and it is in the list generated in #1, this is the user that led to this service call, done, grab the user from HistoricActivityInstance.asignee.
#4) If not #3, find the HistoricActivityInstance whose end time is equal to or just before this activitys start time. If a user task and it is in the list generated in #1, this is the user that led to this service call, done. Else repeat #4 until I find the user task.



Example Diagram:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:smileysurprised:mgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:smileysurprised:mgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="myProcess" name="My process" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="User Task"></userTask>
    <userTask id="usertask2" name="User A Completes This One"></userTask>
    <userTask id="usertask3" name="User B Completes This One"></userTask>
    <serviceTask id="servicetask1" name="Service Task"></serviceTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="usertask2" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="usertask1" targetRef="usertask3"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="usertask3" targetRef="servicetask1"></sequenceFlow>
    <serviceTask id="servicetask2" name="Service Task"></serviceTask>
    <sequenceFlow id="flow6" sourceRef="servicetask1" targetRef="servicetask2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow7" sourceRef="servicetask2" targetRef="endevent1"></sequenceFlow>
    <userTask id="usertask4" name="User C"></userTask>
    <sequenceFlow id="flow8" sourceRef="usertask1" targetRef="usertask4"></sequenceFlow>
    <sequenceFlow id="flow9" sourceRef="usertask4" targetRef="servicetask2"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_myProcess">
    <bpmndi:BPMNPlane bpmnElement="myProcess" id="BPMNPlane_myProcess">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="140.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="250.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="71.0" width="105.0" x="450.0" y="130.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="71.0" width="105.0" x="460.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask1" id="BPMNShape_servicetask1">
        <omgdc:Bounds height="55.0" width="105.0" x="670.0" y="186.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="servicetask2" id="BPMNShape_servicetask2">
        <omgdc:Bounds height="55.0" width="105.0" x="850.0" y="186.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="1000.0" y="196.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask4" id="BPMNShape_usertask4">
        <omgdc:Bounds height="55.0" width="105.0" x="460.0" y="370.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="175.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="302.0" y="240.0"></omgdi:waypoint>
        <omgdi:waypoint x="502.0" y="201.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="555.0" y="165.0"></omgdi:waypoint>
        <omgdi:waypoint x="722.0" y="186.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="355.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="460.0" y="285.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="565.0" y="285.0"></omgdi:waypoint>
        <omgdi:waypoint x="722.0" y="241.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
        <omgdi:waypoint x="775.0" y="213.0"></omgdi:waypoint>
        <omgdi:waypoint x="850.0" y="213.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
        <omgdi:waypoint x="955.0" y="213.0"></omgdi:waypoint>
        <omgdi:waypoint x="1000.0" y="213.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="302.0" y="295.0"></omgdi:waypoint>
        <omgdi:waypoint x="512.0" y="370.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow9" id="BPMNEdge_flow9">
        <omgdi:waypoint x="512.0" y="370.0"></omgdi:waypoint>
        <omgdi:waypoint x="902.0" y="241.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

jbarrez
Star Contributor
Star Contributor
Yes, the historic activity instance does not store the user id currently.
I'm afraid that is indeed the only way if you need that particular bit of information.