Wednesday, April 8, 2020

Sailpoint IIQ Pending Request Details API

Get All the Pending Request Details for the Particular beneficiary , This code will give the below details

Requester
Access Request Number
Identity Request ID
Approval WorkItem ID
Approval WorkItem Pending With
Requester
WorkFlow Case ID
Pending Task ID

public  void getPendingRequestDetails(String beneficiary,SailPointContext context) throws GeneralException {

  String identityRequestID;
  String identityRequestObjectID;
  String accessRequestID = null;
  HashMap returnMap = new HashMap();
  
  Identity identity = context.getObjectByName(Identity.class, beneficiary);
  String beneficiaryName = identity.getName();

  QueryOptions queryOption = new QueryOptions();
  queryOption.addFilter(Filter.eq("targetName", beneficiaryName));
  queryOption.addFilter(Filter.eq("type", "Approval"));
  queryOption.addFilter(Filter.isnull("state"));

  Iterator itWorkItems = context.search(WorkItem.class, queryOption);

  while ((null != itWorkItems) && (itWorkItems.hasNext())) {
   WorkItem workitem = (WorkItem) itWorkItems.next();
   identityRequestID = workitem.getIdentityRequestId();
   if (null != identityRequestID) {
    accessRequestID = new Integer(identityRequestID).toString();
   }  
   if (identityRequestID != null) {
    IdentityRequest irReq = context.getObjectByName(IdentityRequest.class, identityRequestID);
    identityRequestObjectID = irReq.getId();
    
    TaskResult taskResult = context.getObjectById(TaskResult.class,(String)irReq.getAttribute("taskResultId"));    
    WorkflowCase workflowCase = context.getObjectById(WorkflowCase.class,(String) taskResult.getAttribute("workflowCaseId"));
        
    returnMap.put("Access Request Number", accessRequestID);
    returnMap.put("Identity Request ID", identityRequestObjectID);
    returnMap.put("Approval WorkItem ID", workitem.getId());
    returnMap.put("Approval WorkItem Pending", workitem.getOwner().getName());
    returnMap.put("Requester", workitem.getRequester().getName());
    returnMap.put("Task Result ID", (String)irReq.getAttribute("taskResultId"));
    returnMap.put("WorkFlowCase ID", (String) taskResult.getAttribute("workflowCaseId"));
    
   } 
   if (null != workitem && null != workitem.getApprovalSet()) {
    ApprovalSet appSet = workitem.getApprovalSet();
    List approvalItems = appSet.getItems();  
    String entname1 = null;
    for (Object itemObj : approvalItems) {
     String entname = null;
     ApprovalItem item = (ApprovalItem) itemObj;
     if (item.getValue() instanceof String) {
      entname = (String) item.getValue();
      entname1 = entname1 + "||" + entname;
     }
     if (item.getValue() instanceof List) {
      entname = (String) ((List) item.getValue()).get(0);
      entname1 = entname1 + "||" + entname;
     }
    }
   // returnMap.put("Entitlement", entname1);
   }
   System.out.println(returnMap);
  }
  
  sailpoint.tools.Util.flushIterator(itWorkItems);
 } 



{Requester=vkejriwal, Identity Request ID=8a88b861710725440171321c92ed526a, Access Request Number=16899, WorkFlowCase ID=8a88b861710725440171321c91e15265, Approval WorkItem ID=8a88b861710725440171321c98c25270, Task Result ID=8a88b861710725440171321c91dc5264, Approval WorkItem Pending=72349117}
{Requester=aagarwala, Identity Request ID=8a88b861710725440171320d7ebe5222, Access Request Number=16898, WorkFlowCase ID=8a88b861710725440171320d7de6521d, Approval WorkItem ID=8a88b861710725440171320e1214522e, Task Result ID=8a88b861710725440171320d7dd7521c, Approval WorkItem Pending=VIS Fallback Approval Workgroup}