02-27-2013 07:09 PM
<userTask id="confirmApproval" name="Approve the picture request"
activiti:candidateUsers="${user}" activiti:assignee="${user}">
<extensionElements>
<activiti:formProperty id="initiator" name="Initiator:"
type="string" />
<activiti:formProperty id="approvalConfirmed"
name="approvalConfirmed" type="enum" required="true">
<activiti:value id="true" name="Yes"></activiti:value>
<activiti:value id="false" name="No"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
public class ArchiveTask implements org.activiti.engine.delegate.JavaDelegate
{
public void execute(DelegateExecution execution) throws Exception {
Map<String, String> properties = new HashMap<String, String>();
String assigneeName = (String) execution.getVariable("user");
boolean approval = (Boolean) execution.getVariable("needsApproval");
TaskService taskService = execution.getEngineServices()
.getTaskService();
List<Task> tasks = taskService.createTaskQuery()
.taskAssignee(assigneeName).list();
for (Task task : tasks) {
task.setOwner(assigneeName);
}
ProcessDefinition definition = execution.getEngineServices().getRepositoryService()
.createProcessDefinitionQuery().processDefinitionKey("pictureRequestNew").singleResult();
FormService formService = execution.getEngineServices()
.getFormService();
List<FormProperty> formList = formService.getStartFormData(definition.getId()).getFormProperties();
System.out.println(formList.size()+" Form List size");
System.out.println(definition.getId()+" Definition Id ");
try {
properties = new HashMap<String, String>();
properties.put("initiator", "kermit");
properties.put("approvalConfirmed", "Yes");
formService.submitTaskFormData(definition.getId(), properties);
} catch (ActivitiException e) {
}
}
}
02-28-2013 02:39 AM
02-28-2013 12:10 PM
<process id="pictureRequestNew" name="Testing Complex Approval process">
<startEvent id="theStart" activiti:initiator="initiator" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="needsApprovalTask" />
<serviceTask id="needsApprovalTask" name="Needs approval"
activiti:class="com.picturerequest.NeedsApprovalDelegate" />
<sequenceFlow id="flow2" sourceRef="needsApprovalTask"
targetRef="gateway" />
<exclusiveGateway id="gateway" name="Needs approval?" />
<sequenceFlow id="flow3" sourceRef="gateway" targetRef="confirmApproval">
<conditionExpression xsi:type="tFormalExpression">
${needsApproval}
</conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" sourceRef="gateway" targetRef="Email">
<conditionExpression xsi:type="tFormalExpression">
${!needsApproval}
</conditionExpression>
</sequenceFlow>
<userTask id="confirmApproval" name="Approve the picture request"
activiti:candidateUsers="${user}" activiti:assignee="${user}">
<extensionElements>
<activiti:formProperty id="initiator" name="Initiator:"
type="string" />
<activiti:formProperty id="approvalConfirmed"
name="approvalConfirmed" type="enum" required="true">
<activiti:value id="true" name="Yes"></activiti:value>
<activiti:value id="false" name="No"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="flow5" sourceRef="confirmApproval"
targetRef="gateway2" />
<exclusiveGateway id="gateway2" name="Is approval confirmed?" />
<sequenceFlow id="flow6" sourceRef="gateway2" targetRef="chargeAccount">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'true'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow7" sourceRef="gateway2" targetRef="ArchiveTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'false'}]]></conditionExpression>
</sequenceFlow>
<serviceTask id="Email" name="Email Service"
activiti:class="com.picturerequest.ChargeDelegate">
<extensionElements>
<activiti:field name="wsdl"
expression="http://localhost:8521/mailService?wsdl" />
<activiti:field name="operation" expression="chargeAccount" />
<activiti:field name="parameters" expression="${user}, ${imageName}" />
<activiti:field name="returnValue" expression="myReturn" />
</extensionElements>
</serviceTask>
<serviceTask id="chargeAccount" name="Charge account"
activiti:class="com.picturerequest.ChargeDelegate">
<extensionElements>
<activiti:field name="wsdl"
expression="http://localhost:8291/chargeService?wsdl" />
<activiti:field name="operation" expression="chargeAccount" />
<activiti:field name="parameters" expression="${user}, ${imageName}" />
<activiti:field name="returnValue" expression="myReturn" />
</extensionElements>
</serviceTask>
<sequenceFlow id="flow10" sourceRef="chargeAccount"
targetRef="ArchiveTask" />
<sequenceFlow id="flow13" sourceRef="Email" targetRef="theEnd" />
<serviceTask id="ArchiveTask" name="serviceTask"
activiti:class="com.picturerequest.ArchiveTask">
</serviceTask>
<sequenceFlow id="flow8" sourceRef="ArchiveTask"
targetRef="theEnd" />
<endEvent id="theEnd" />
</process>
</definitions>
public class ArchiveTask implements org.activiti.engine.delegate.JavaDelegate
{
public void execute(DelegateExecution execution) throws Exception {
Map<String, String> properties = new HashMap<String, String>();
String assigneeName = (String) execution.getVariable("user");
boolean approval = (Boolean) execution.getVariable("needsApproval");
TaskService taskService = execution.getEngineServices()
.getTaskService();
List<Task> tasks = taskService.createTaskQuery()
.taskAssignee(assigneeName).list();
for (Task task : tasks) {
task.setOwner(assigneeName);
}
ProcessDefinition definition = execution.getEngineServices().getRepositoryService()
.createProcessDefinitionQuery().processDefinitionKey("pictureRequestNew").singleResult();
FormService formService = execution.getEngineServices()
.getFormService();
List<FormProperty> formList = formService.getTaskFormData(definition.getId()).getFormProperties(); // Throws error
try {
properties = new HashMap<String, String>();
properties.put("initiator", "kermittttttttt");
properties.put("approvalConfirmed", "Yes");
formService.submitTaskFormData(definition.getId(), properties); // throws error
} catch (ActivitiException e) {
}
}
03-01-2013 04:00 AM
List<FormProperty> formList = formService.getTaskFormData(definition.getId()).getFormProperties(); // Throws below error
03-01-2013 12:24 PM
List<FormProperty> formList = formService.getTaskFormData(definition.getId()).getFormProperties(); // Throws below error
You get the task-form using the task-id on formService.getTaskFormData OR you use process-definition-id to get start-form-properties using getStartForm(…). In your case, you just want the stuff that is in the task.
I'm not really sure what your use case is… Are you staring a new process from within another process, posting form-properties to the new process?
<userTask id="confirmApproval" name="Approve the picture request"
activiti:candidateUsers="${user}" activiti:assignee="${user}">
<extensionElements>
<activiti:formProperty id="approvalFlag" name="Needs Approval:"
expression="${needsApproval}" writable="false" type="boolean" />
<activiti:formProperty id="initiatorName" name="Initiator:"
expression="${initiator}" writable="false" type="string" />
<activiti:formProperty id="descriptionValue" name="Description:"
expression="${description}" readable="true" writable="false" type="string" />
<activiti:formProperty id="userName" name="User:"
expression="${user}" writable="false" type="string" />
<activiti:formProperty id="imageName" name="Image:"
expression="${imageName}" writable="false" type="string" />
<activiti:formProperty id="approvalConfirmed"
name="approvalConfirmed" type="enum" required="true">
<activiti:value id="true" name="Yes"></activiti:value>
<activiti:value id="false" name="No"></activiti:value>
</activiti:formProperty>
</extensionElements>
</userTask>
<sequenceFlow id="flow5" sourceRef="confirmApproval" targetRef="gateway2" />
<exclusiveGateway id="gateway2" name="Is approval confirmed?" />
<sequenceFlow id="flow6" sourceRef="gateway2" targetRef="chargeAccount">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'true'}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow7" sourceRef="gateway2" targetRef="ArchiveTask">
<conditionExpression xsi:type="tFormalExpression"><![CDATA[${approvalConfirmed == 'false'}]]> </conditionExpression>
</sequenceFlow>
<serviceTask id="chargeAccount" name="Charge" activiti:class="com.picturerequest.ChargeAccount" />
<sequenceFlow id="flowNew" sourceRef="chargeAccount" targetRef="ArchiveTask" />
<serviceTask id="ArchiveTask" name="ArchiveData" activiti:class="com.picturerequest.ArchiveTask" />
<sequenceFlow id="flow8" sourceRef="ArchiveTask" targetRef="theEnd" />
TaskFormData formData = formService.getTaskFormData(task1.getId());
task1.setOwner("fozzie");
List<FormProperty> formList = formService.getTaskFormData(formData.getTask().getId()).getFormProperties();
properties = new HashMap<String, String>();
properties.put("approvalFlag", formList.get(0).getValue());
properties.put("initiatorName",formList.get(1).getValue());
properties.put("descriptionValue", formList.get(2).getValue());
properties.put("userName", formList.get(3).getValue());
properties.put("imageName",formList.get(4).getValue());
properties.put("approvalConfirmed",formList.get(5).getValue());
formService.submitTaskFormData(formData.getTask().getId(), properties);
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.