How to handle access request Unverified

One of the work item Access request is Unverified and if i look inside it its completionStatus is pending but ExecutingStatus is completed. My this script is not updating it .


  import sailpoint.object.QueryOptions;
  import sailpoint.object.IdentityRequest;
  import sailpoint.object.Filter;
  import sailpoint.tools.Util;
  import sailpoint.tools.Message;

  try {
    int daysToDelete = 30;

    // Calculate the cutoff date
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, -daysToDelete);
    Date beforeDate = cal.getTime();

    // Create QueryOptions to filter IdentityRequests
    QueryOptions qo = new QueryOptions();
    qo.addFilter(Filter.lt("created", beforeDate));
    qo.addFilter(Filter.or(
      Filter.eq("completionStatus", "Pending"),
      Filter.eq("executionStatus", "Executing")
    ));

    // Search for matching IdentityRequests
    Iterator iterator = context.search(IdentityRequest.class, qo);
    if (null != iterator) {
      while (iterator.hasNext()) {
        IdentityRequest identityRequest = (IdentityRequest) iterator.next();
        if (null != identityRequest) {
          
          // Update the IdentityRequest
          identityRequest.setExecutionStatus(IdentityRequest.ExecutionStatus.Completed); // Updated
          identityRequest.setCompletionStatus(IdentityRequest.CompletionStatus.Success); // Updated
          
          context.saveObject(identityRequest);
        }
      }
      context.commitTransaction();
      Util.flushIterator(iterator);
    }
  } catch (Exception e) {
    // Block of code to handle errors
    e.printStackTrace(); // Optional: print stack trace for debugging
  }

hi @autorun6464

Do this one also.

         if(null != taskResult && null != taskResult.getAttribute("workflowCaseId"))
          {
            WorkflowCase workflowCase = context.getObjectById(WorkflowCase.class, taskResult.getAttribute("workflowCaseId"));
            if(null != workflowCase)
            {
              workflower.terminate(workflowCase);
            }
            //terminator.deleteObject(taskResult);
          }
1 Like

Sharing the link that would helpful for you. And, you can check your code and adjust the logic accordingly.

1 Like

@autorun6464

try by adding these details also.

Date date = new Date(); 
identityRequest.setVerified(date);
identityRequest.setEndDate(date);
identityRequest.setState("End");

Your code should be like below,

import sailpoint.object.QueryOptions;
  import sailpoint.object.IdentityRequest;
  import sailpoint.object.Filter;
  import sailpoint.tools.Util;
  import sailpoint.tools.Message;

  try {
    int daysToDelete = 30;

    // Calculate the cutoff date
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, -daysToDelete);
    Date beforeDate = cal.getTime();

    // Create QueryOptions to filter IdentityRequests
    QueryOptions qo = new QueryOptions();
    qo.addFilter(Filter.lt("created", beforeDate));
    qo.addFilter(Filter.or(
      Filter.eq("completionStatus", "Pending"),
      Filter.eq("executionStatus", "Executing")
    ));

    // Search for matching IdentityRequests
    Iterator iterator = context.search(IdentityRequest.class, qo);
    if (null != iterator) {
      while (iterator.hasNext()) {
        IdentityRequest identityRequest = (IdentityRequest) iterator.next();
        if (null != identityRequest) {
          
          // Update the IdentityRequest
          identityRequest.setExecutionStatus(IdentityRequest.ExecutionStatus.Completed); // Updated
          identityRequest.setCompletionStatus(IdentityRequest.CompletionStatus.Success); // Updated
          Date date = new Date(); 
          identityRequest.setVerified(date);
          identityRequest.setEndDate(date);
          identityRequest.setState("End");
          
          context.saveObject(identityRequest);
        }
      }
      context.commitTransaction();
      Util.flushIterator(iterator);
    }
  } catch (Exception e) {
    // Block of code to handle errors
    e.printStackTrace(); // Optional: print stack trace for debugging
  }

let me know if that works.

1 Like

nope didnt work thou

Hi @autorun6464,

The code will update the status of IdentityRequests that were created 30 days ago. Was your IdentityRequest created 30 days ago?

If you want to change the status of a specific IdentityRequest, you can directly specify the IdentityRequest in the code instead of using a query filter.
Are you encountering any error messages during execution of this rule?

Regards,
Arun

Are you getting any error? Or simply not executing and coming out?

Could you please share the code after updating?? So that we can tell you where exactly the issue? I hope you have updated the code.

yes my updated code… like it is updating all other request older than 30 days but one of them is unverified state which is not getting updated … so i wanted to knw ways to handle unverified requests

import sailpoint.object.QueryOptions;
  import sailpoint.object.IdentityRequest;
  import sailpoint.object.Filter;
  import sailpoint.tools.Util;
  import sailpoint.tools.Message;

  try {
    int daysToDelete = 30;

    // Calculate the cutoff date
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_MONTH, -daysToDelete);
    Date beforeDate = cal.getTime();

    // Create QueryOptions to filter IdentityRequests
    QueryOptions qo = new QueryOptions();
    qo.addFilter(Filter.lt("created", beforeDate));
    qo.addFilter(Filter.or(
      Filter.eq("completionStatus", "Pending"),
      Filter.eq("executionStatus", "Executing")
    ));

    // Search for matching IdentityRequests
    Iterator iterator = context.search(IdentityRequest.class, qo);
    if (null != iterator) {
      while (iterator.hasNext()) {
        IdentityRequest identityRequest = (IdentityRequest) iterator.next();
        if (null != identityRequest) {
          
          // Update the IdentityRequest
          identityRequest.setExecutionStatus(IdentityRequest.ExecutionStatus.Completed); // Updated
          identityRequest.setCompletionStatus(IdentityRequest.CompletionStatus.Success); // Updated
          Date date = new Date(); 
          identityRequest.setVerified(date);
          identityRequest.setEndDate(date);
          identityRequest.setState("End");
          
          context.saveObject(identityRequest);
        }
      }
      context.commitTransaction();
      Util.flushIterator(iterator);
    }
  } catch (Exception e) {
    // Block of code to handle errors
    e.printStackTrace(); // Optional: print stack trace for debugging
  }

it is updating all other request older than 30 days but one of them is unverified state which is not getting updated … so i wanted to know ways to update unverified requests…

Hi @autorun6464 ,

What I am thinking is, first, check if the identity request is coming or not in the loop by just adding a log statement. I am suspecting the identity request is not coming because you have added two filters while getting. Maybe, those filters are filtering out. To confirm that, please check the identity request from debug and check those values (completionStatus is Pending and executionStatus is Executing) if those values are there, whatever you used in the filter. Those only will come. Otherwise, those won’t come. If the identity request does not contain either of two values, then probably that is the reason why it is not coming into loop.

If it is not coming in the loop, please try to add or update the filter as well, whatever the value is, after checking from debug.

Ultimatly, the identity request should come in the loop, and then only you can update, that is what I want to say. Please try that and let me know.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.