bbarani (8) [Avatar] Offline
#1
Hi,

Can someone let me know how to implement an auto approval process.

For example, the below custom form should get auto approved and stored in archive based on the request but as of now someone has to get in to the system to approve this task. I am passing the data to populate the form, hence I need those details for future reporting hence I cant just bypass the form without archiving it.

<userTask id="NoNeedApproval" name="Auto Approval" >
activiti:candidateUsers="${user}" activiti:assignee="${user}">
<extensionElements>
<activiti:formProperty id="test6" name="Needs Approval:" >
expression="${needsApproval}" writable="false" type="boolean" />

<activiti:formProperty id="test3" name="Initiator:" >
expression="${initiator}" writable="false" type="string" />

<activiti:formProperty id="test3" name="Description:" >
expression="${description}" readable="true" writable="false" type="string" />

<activiti:formProperty id="test" name="User:" >
expression="${user}" writable="false" type="string" />

<activiti:formProperty id="test2" 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>


I have the below java class to archive the form but I am not sure how to invoke the class automatically from this user task..

{
public void execute(DelegateExecution execution) throws Exception {
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);

}

}
}

Thanks,
Barani