1 Reply Latest reply on Feb 12, 2015 4:34 AM by kuopching

    Choose User Action in Task programmatically

    PeterWByrne Level 1

      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. Re: Choose User Action in Task programmatically
          kuopching Level 1

          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);