cancel
Showing results for 
Search instead for 
Did you mean: 

can i send user task form elements to task listner with any way ?

rakesh_world86
Champ in-the-making
Champ in-the-making
in this xml , there is a string ,
<blockcode>
<activiti:field name="fldLicenseApprove">
</blockcode>
i want to send user task form elements to task listner ,
thats why i want to save these values in custom database using Java TaskListener.

i am unable to send usertask form data to task listner . i have tried a lot but got unsuccessfull.

pls help me . i am stuck in this since 2 days.

<blockcode>
<?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" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://activiti.org/bpmn20" id="definitions">
  <process id="ApplyForLicenseCallBackGz9" name="New Xml for Apply for license" isExecutable="true">
    <startEvent id="request" activiti:initiator="employeeName">
      <extensionElements>
        
        <activiti:formProperty id="licenseHolderName" name="licenseHolderName" type="string" required="true"></activiti:formProperty>
      </extensionElements>
    </startEvent>
    <sequenceFlow id="flow1" sourceRef="request" targetRef="handleRequest"></sequenceFlow>
    <userTask id="handleRequest" name="Handle license request" activiti:assignee="kermitGz9">
      <documentation>{"estimateHours":"48 Hrs","documentation":"${licenseHolderName} has applied for license","label":"Apply for license","id":"ApplyForLicense"}.</documentation>
      <extensionElements>
        <activiti:formProperty id="licenseApproved" name="Do you approve this license" type="string" required="true"></activiti:formProperty>
        <activiti:formProperty id="Comments" name="Comments" type="string"></activiti:formProperty>
       
        <activiti:taskListener event="create" expression="${myobject.join(task,task.eventName,'customText')}">
           <activiti:field name="fldLicenseApprove">
              <activiti:string>
               ${licenseApproved}
               </activiti:string>
          </activiti:field>
       </activiti:taskListener>
       <activiti:taskListener event="complete" class="org.ReverseStringsFieldInjected1">
           <activiti:field name="text">
              <activiti:string>
                   ${licenseApproved}
               </activiti:string>
          </activiti:field>
       </activiti:taskListener>
       
      </extensionElements>
    </userTask>
    <sequenceFlow id="flow2" sourceRef="handleRequest" targetRef="requestApprovedDecision"></sequenceFlow>
    <exclusiveGateway id="requestApprovedDecision" name="Request approved?" default="sendApprovalMail"></exclusiveGateway>
    <sequenceFlow id="flow3" sourceRef="requestApprovedDecision" targetRef="sendApprovalMail">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${licenseApproved == 'true'}]]></conditionExpression>
    </sequenceFlow>
   
    <userTask id="sendApprovalMail" name="Java service invocation">
       <documentation>manager has approved license request.</documentation>
   </userTask>
    
   <sequenceFlow id="flow4" sourceRef="sendApprovalMail" targetRef="theEnd1"></sequenceFlow>
    <endEvent id="theEnd1"></endEvent>
    <sequenceFlow id="flow5" sourceRef="requestApprovedDecision" targetRef="adjustLicenseRequestTask">
      <conditionExpression xsi:type="tFormalExpression"><![CDATA[${licenseApproved == 'false'}]]></conditionExpression>
    </sequenceFlow>
    <userTask id="adjustLicenseRequestTask" name="Reject License Approval">
      <documentation>Your manager has disapproved your license request . Reason: ${Comments}</documentation>
    </userTask>
    <endEvent id="theEnd2"></endEvent>
    <sequenceFlow id="flow6" sourceRef="adjustLicenseRequestTask" targetRef="theEnd2"></sequenceFlow>
  </process>
</definitions>
</blockcode>
1 REPLY 1

balsarori
Champ on-the-rise
Champ on-the-rise
Submitted form values are accessible as process variables. To access them from a TaskListener, use the following

[java]
public class SaveFormValues implements TaskListener {
  public void notify(DelegateTask delegateTask) {
    Object licenseApproved = delegateTask.getVariable("licenseApproved");
    Object comments = delegateTask.getVariable("Comments");
// add your logic here to save submitted form values
  }
}
[/java]

Of course, your TaskListener should be registered on complete event, as follows

<activiti:taskListener event="complete" class="org.example.SaveFormValues" />