Hi, I'm creating a servlet that's using the following method to get the

Hi, I'm creating a servlet that's using the following method to get the first task ID from an array of task ids, where the task status is NOT accepted. For some reason, every time I activate the servlet, I'm seeing the same task ID being returned by the method. I'm including both the code and the logging info I have below. Does anyone have any idea why this may not be working?

Log:
19:08:05,574 INFO [stdout] (ajp-/0.0.0.0:8009-33) 2015-03-18 19:08:05,574 [ajp-/0.0.0.0:8009-33] ERROR com.snl.appian.servlets.rapidaccept.RapidAccept - Adding User Context to Task Report: nickw
19:08:05,747 INFO [stdout] (ajp-/0.0.0.0:8009-33) 2015-03-18 19:08:05,747 [ajp-/0.0.0.0:8009-33] ERROR com.snl.appian.servlets.rapidaccept.RapidAccept - Finding first unaccepted task with status 1...
19:08:05,752 INFO [stdout] (ajp-/0.0.0.0:8009-33) 2015-03-18 19:08:05,752 [ajp-/0.0.0.0:8009-33] ERROR com.snl.appian.servlets.rapidaccept.RapidAccept - Status {1} for task id:537139...

OriginalPostID-142017

OriginalPostID-142017

  Discussion posts and replies are publicly visible

  • ...629
    19:08:05,752 INFO [stdout] (ajp-/0.0.0.0:8009-33) 2015-03-18 19:08:05,752 [ajp-/0.0.0.0:8009-33] ERROR com.snl.appian.servlets.rapidaccept.RapidAccept - Attempting to accept task id 537139629for user nickw
    19:08:05,754 INFO [stdout] (ajp-/0.0.0.0:8009-33) 2015-03-18 19:08:05,754 [ajp-/0.0.0.0:8009-33] ERROR com.snl.appian.servlets.rapidaccept.RapidAccept - Task ID 537139629 accepted for user nickw

    private Long GetFirstUnacceptedTask(ProcessExecutionService pes, Long[] taskIds) throws InvalidActivityException, PrivilegeException
              {
                         debugLog("Finding first unaccepted task with status " + TaskSummary.TASK_STATUS_ACCEPTED + "...");
                        
                         for (Long ID : taskIds)
                         {
                                   TaskDetails details = pes.getTaskDetails(ID);
                                   Integer status = details.getStatus();
                                  
                                   debugLog("Status {" + status + "} for task id:" + ID);
                                  
                                   // Check if the task has been accepted
                                   if (status != TaskSummary.TASK_STATUS_ACCEPTED)
                                   {
                                             // If not, return this task id...
  • ... so it can be accepted
                                             return ID;
                                   }
                         }
                        
                         return null;
               }

    Thanks!
  • 0
    Certified Lead Developer
    Are you filtering out completed tasks from your ID list? Take a look at the taskID that keeps getting returned (is it completed? is it assigned? if assigned, then try accepting it and run the servlet again)
  • Well, you return from the for loop as soon as you find a task that is not accepted. Apparently, the array that is sent to this method has the same task ID in it. Do you change the status after the call to this method?