Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Choose User Action in Task programmatically

Avatar

Former Community Member

I have a process that has two tasks that is a simple 'approval' process.  I need to be able to programmatically choose either 'Approved' or 'Rejected' for a task so that the process goes to the next task assignment or exits the process and the process ends.

From code how do you get the current task of a process, and action one of the user actions?

Thanks!

1 Reply

Avatar

Level 2

Hi,  try this for ES3

ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);

long processId = YOUR_PROCESS_ID;

ProcessManagementQueryService queryService = ProcessManagementClientFactory.getProcessManagementQueryService(myFactory);

List<Task> lst= queryService.getTasksForProcessInstance(processId);

String taskId = lst.get(0).getTaskId() + ""; // i think, the current task is first at collection

String route ="YOUR ROUTE NAME";

ProcessManagementTaskService taskService=ProcessManagementClientFactory.getProcessManagementTaskService(myFactory);

taskService.submitWithPriorData(taskId, "");

taskService.complete(taskId, route);