AnsweredAssumed Answered

Start a process instance as a different user than the one who deployed it

Question asked by kiranchandran.kc on Apr 11, 2016
Latest reply on Apr 12, 2016 by jbarrez
Hi,

I am using Activiti-app 1.4.1.
We are calling activiti workflow suing REST APIs through our custom application. My requirement is that I wanted to start the activiti workflow process instance by the name of the user who logs into our custom application.

For example : As an Admin, I have defined a process definition, created an app and deployed it. I created two groups as well. If an user(user01@test.com) logs into my custom application I would make a REST call to activiti to start the process instance deployed by admin. I can do it with Admin credentials. But in that case I won't be able to track via activiti-app, who started the process. How should I  start the process as user01 using REST API?

Any help would be appreciated. Posting my bpmn code as well.

<?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:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="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="GPCWorkflow_Basic" name="GPC Workflow Basic" isExecutable="true" activiti:candidateStarterGroups="oeContacts,gpcAdmin">
    <startEvent id="startOEWorkflow" name="StartOEWorkFlow" activiti:initiator="oeContacts" activiti:formKey="start GPC Workflow"></startEvent>
    <sequenceFlow id="flow1" sourceRef="startOEWorkflow" targetRef="oe_draft"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="oe_draft" targetRef="oe_submitted"></sequenceFlow>
    <exclusiveGateway id="exclusivegateway1" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="finalFlow" name="Final Flow" sourceRef="exclusivegateway1" targetRef="oe_final">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${sendtooe .equals("false")}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="flow8" sourceRef="oe_submitted" targetRef="exclusivegateway1"></sequenceFlow>
    <sequenceFlow id="sendtoOE" name="send to OE" sourceRef="exclusivegateway1" targetRef="gpc_sendtoOE">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${sendtooe .equals("true")}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="oe_draft" name="Draft" activiti:candidateGroups="oeContacts">
      <documentation>The OE form is opened in Draft status. The status won't change until all the validations are fulfilled.</documentation>
    </userTask>
    <userTask id="oe_submitted" name="Submitted to GP&amp;C" activiti:candidateGroups="gpcAdmin"></userTask>
    <exclusiveGateway id="exclusivegateway2" name="Exclusive Gateway"></exclusiveGateway>
    <sequenceFlow id="flow12" sourceRef="oe_final" targetRef="exclusivegateway2"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="gpc_complete" name="complete task" sourceRef="exclusivegateway2" targetRef="endevent1">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${reopen.equals("false")}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="gpc_reopen" name="Reopen" sourceRef="exclusivegateway2" targetRef="gpc_sendtoOE">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${reopen.equals("true")}]]></conditionExpression>
    </sequenceFlow>
    <sequenceFlow id="oe_resubmit" name="Re Submit" sourceRef="gpc_sendtoOE" targetRef="oe_submitted"></sequenceFlow>
    <userTask id="oe_final" name="Final"></userTask>
    <userTask id="gpc_sendtoOE" name="Send to OE" activiti:candidateGroups="oeContacts"></userTask>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_GPCWorkflow_Basic">
    <bpmndi:BPMNPlane bpmnElement="GPCWorkflow_Basic" id="BPMNPlane_GPCWorkflow_Basic">
      <bpmndi:BPMNShape bpmnElement="startOEWorkflow" id="BPMNShape_startOEWorkflow">
        <omgdc:Bounds height="35.0" width="35.0" x="140.0" y="260.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway1" id="BPMNShape_exclusivegateway1">
        <omgdc:Bounds height="40.0" width="40.0" x="820.0" y="258.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="oe_draft" id="BPMNShape_oe_draft">
        <omgdc:Bounds height="75.0" width="105.0" x="220.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="oe_submitted" id="BPMNShape_oe_submitted">
        <omgdc:Bounds height="75.0" width="105.0" x="460.0" y="241.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="exclusivegateway2" id="BPMNShape_exclusivegateway2">
        <omgdc:Bounds height="40.0" width="40.0" x="1120.0" y="258.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="1205.0" y="261.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="oe_final" id="BPMNShape_oe_final">
        <omgdc:Bounds height="55.0" width="105.0" x="970.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="gpc_sendtoOE" id="BPMNShape_gpc_sendtoOE">
        <omgdc:Bounds height="76.0" width="105.0" x="790.0" y="380.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="175.0" y="277.0"></omgdi:waypoint>
        <omgdi:waypoint x="220.0" y="277.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="325.0" y="277.0"></omgdi:waypoint>
        <omgdi:waypoint x="460.0" y="278.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="finalFlow" id="BPMNEdge_finalFlow">
        <omgdi:waypoint x="860.0" y="278.0"></omgdi:waypoint>
        <omgdi:waypoint x="970.0" y="277.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="49.0" x="870.0" y="286.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
        <omgdi:waypoint x="565.0" y="278.0"></omgdi:waypoint>
        <omgdi:waypoint x="820.0" y="278.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="sendtoOE" id="BPMNEdge_sendtoOE">
        <omgdi:waypoint x="840.0" y="298.0"></omgdi:waypoint>
        <omgdi:waypoint x="842.0" y="380.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="53.0" x="850.0" y="330.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow12" id="BPMNEdge_flow12">
        <omgdi:waypoint x="1075.0" y="277.0"></omgdi:waypoint>
        <omgdi:waypoint x="1120.0" y="278.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="gpc_complete" id="BPMNEdge_gpc_complete">
        <omgdi:waypoint x="1160.0" y="278.0"></omgdi:waypoint>
        <omgdi:waypoint x="1205.0" y="278.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="66.0" x="1159.0" y="294.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="gpc_reopen" id="BPMNEdge_gpc_reopen">
        <omgdi:waypoint x="1140.0" y="298.0"></omgdi:waypoint>
        <omgdi:waypoint x="1139.0" y="417.0"></omgdi:waypoint>
        <omgdi:waypoint x="895.0" y="418.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="37.0" x="1011.0" y="429.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="oe_resubmit" id="BPMNEdge_oe_resubmit">
        <omgdi:waypoint x="790.0" y="418.0"></omgdi:waypoint>
        <omgdi:waypoint x="513.0" y="418.0"></omgdi:waypoint>
        <omgdi:waypoint x="512.0" y="316.0"></omgdi:waypoint>
        <bpmndi:BPMNLabel>
          <omgdc:Bounds height="14.0" width="48.0" x="591.0" y="430.0"></omgdc:Bounds>
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Outcomes