Retrieving all the pending/Open tasks from task result

Hi,

We are trying to retrieve tasks that are in a pending state by using the completionStatus field of TaskResult as shown below:

TaskResult.CompletionStatus statusObj = result.getCompletionStatus();

If statusObj is null, we consider the task as pending/open and retrieve all such tasks. However, while retrieving, we are not able to get the pending tasks. Could anyone help or suggest an approach for the above scenario.

Thanks,

Akash

Hi @AkashRaavi131 ,

Could you try using this code to retrieve the pending tasks.

 import sailpoint.object.TaskResult;
  import sailpoint.object.TaskResult.CompletionStatus;
  import org.apache.log4j.Logger;
  import java.util.List;
  import java.util.ArrayList;

  import sailpoint.object.QueryOptions;
  import sailpoint.object.Filter;

  import sailpoint.tools.Util;
  import java.util.Iterator;

  List pendingTasks = new ArrayList();

  QueryOptions options = new QueryOptions();

  options.addFilter(Filter.isnull("completionStatus"));

  Iterator iterator = context.search(TaskResult.class,options,"name");

  while(iterator!=null && iterator.hasNext()){

    Object[] taskNames = (Object[]) iterator.next();

    pendingTasks.add((String) taskNames[0]);

  }

  Util.flushIterator(iterator);

  return pendingTasks;

1 Like