Showing posts with label workitem. Show all posts
Showing posts with label workitem. Show all posts

Thursday, November 16, 2023

IdentityIQ Sailpoint Show only Active Manager in Workitem forwarding


            <entry key="ReassignmentRecipient">
              <value>
                <IdentityFilter name="ReassignmentRecipient" order="Ascending">
                  <FilterScript>
                    <Script>
                      <Source>
                        import sailpoint.object.Identity;
                        import sailpoint.object.QueryOptions;
                        import sailpoint.object.Filter;
                        import java.util.List;
                        import java.util.ArrayList;

                        Identity identity = context.getObjectById(Identity.class, loggedInUser);
                        if(identity == null){
                          identity = context.getObjectByName(Identity.class, loggedInUser);
                        }
                        QueryOptions qo = new QueryOptions();
                        List managers = new ArrayList();
                        int managerLevels = 2;
                        int maxIterations = 15;
                        if(identity != null){
                          int level = 0;
                          int iter = 0;
                          while((level &lt; managerLevels) &amp;&amp; (iter &lt; maxIterations)){
                             iter++;
                             Identity manager = identity.getManager();
                             if(null == manager)
                               break;
                             if(!manager.isInactive()){
                               managers.add(manager.getId());
                               level++;
                             }
                             identity = manager;
                          }
                        }
                        qo.addFilter(Filter.in("id",managers));
                        return qo;
                        </Source>
                    </Script>
                  </FilterScript>
                  <OrderBy>
                    <String>firstname</String>
                  </OrderBy>
                </IdentityFilter>
              </value>
            </entry>


            ownerNameSuggestBoxApprovalForward
            ownerNameSuggestBoxWorkItemListForward

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}