AnsweredAssumed Answered

Accessing Form Variable in a subsequent shell task

Question asked by sandeep1 on Aug 28, 2014
Latest reply on Aug 30, 2014 by jbarrez
Hi

I have a simple workflow Start -> User task(form) -> Shell Task -> End.
In the User task form i get the User to fill a form and set the value to a Process variable(SYSTEMNAME).
Now i want to access the variable in the Shell Task as one of the arguments to the shell command.
How can i access it?

My bpmn is as below.

<?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="CreatePxeHyperVisor" name="Create Pxe For Hyper Visor" isExecutable="true">
    <startEvent id="startcreatepxehyper" name="StartCreatePxeHyper"></startEvent>
    <serviceTask id="createPxeHyperVisor" name="createPxeHyperVisor" activiti:type="shell">
      <extensionElements>
        <activiti:field name="command">
          <activiti:string><![CDATA[/opt/misserver/scripts/create_esxi_pxe_configurations.sh]]></activiti:string>
        </activiti:field>
        <activiti:field name="arg1">
          <activiti:string><![CDATA[-c]]></activiti:string>
        </activiti:field>
        <activiti:field name="arg2">
          <activiti:string><![CDATA[/var/${SYSTEMNAME}_cluster_info.txt]]></activiti:string>
        </activiti:field>
        <activiti:field name="wait">
          <activiti:string><![CDATA[true]]></activiti:string>
        </activiti:field>
        <activiti:field name="outputVariable">
          <activiti:string><![CDATA[resultVar]]></activiti:string>
        </activiti:field>
      </extensionElements>
    </serviceTask>
    <endEvent id="endcreatepxehyper" name="EndCreatePxeHyper"></endEvent>
    <sequenceFlow id="flow2" sourceRef="createPxeHyperVisor" targetRef="endcreatepxehyper"></sequenceFlow>
    <userTask id="getSystemName" name="Get system name" activiti:assignee="kermit">
      <extensionElements>
        <activiti:formProperty id="systemName" name="System Name" variable="SYSTEMNAME" required="true"></activiti:formProperty>
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow3" sourceRef="startcreatepxehyper" targetRef="getSystemName"></sequenceFlow>
    <sequenceFlow id="flow4" sourceRef="getSystemName" targetRef="createPxeHyperVisor"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_CreatePxeHyperVisor">
    <bpmndi:BPMNPlane bpmnElement="CreatePxeHyperVisor" id="BPMNPlane_CreatePxeHyperVisor">
      <bpmndi:BPMNShape bpmnElement="startcreatepxehyper" id="BPMNShape_startcreatepxehyper">
        <omgdc:Bounds height="35.0" width="35.0" x="60.0" y="180.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="createPxeHyperVisor" id="BPMNShape_createPxeHyperVisor">
        <omgdc:Bounds height="55.0" width="105.0" x="280.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endcreatepxehyper" id="BPMNShape_endcreatepxehyper">
        <omgdc:Bounds height="35.0" width="35.0" x="430.0" y="180.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="getSystemName" id="BPMNShape_getSystemName">
        <omgdc:Bounds height="55.0" width="105.0" x="140.0" y="170.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="385.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="430.0" y="197.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="95.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="140.0" y="197.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="245.0" y="197.0"></omgdi:waypoint>
        <omgdi:waypoint x="280.0" y="197.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

Regards,
Sandeep.J

Outcomes