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
}
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?
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…
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.