Share all details related to your problem, including any error messages you may have received.
I am trying to write a rule to send notifications for failed scheduled tasks. So far , this is what I have.
QueryOptions qo = new QueryOptions();
Filter f1 = Filter.and(Filter.notnull(“schedule”),Filter.ne(“type”,“liveReport”);
Filter f2 = Filter.notnull(“completed”);
qo.addFilter(Fitter.and(f1,f2));
Iterator it = context.search(TaskResult.class,qo);
The problem with this though is its bringing taskresults of several unwanted types like “system”, “certification” etc. What would be the best way to do this?
Have you tried storing the names of the required scheduled task names in a custom object and then using that custom object to query and see if that particular list of scheduled tasks failed?
Is liveReport a custom task? Because I didn’t find a task of this type in the list.
It would be really helpful if you can attach task result from the object browser for your task.
Secon for fetching Failed tasks you should also add a filter stating completionStatus=“Fail”.
I dont have my work laptop . I think I added that filter initially to exclude scheduled reports. Later I realized , there are a lot more than scheduled reports I need to exclude.
Also, I have seen failed task with completion status of both “Error” and “Failed” . I did not want to add another AND filter for these conditions. I am checking for that here:
while (it != null && it.hasNext()) {
TaskResult tr = (TaskResult) it1.next();
sailpoint.object.TaskItemDefinition.Type type = tr.getType();
if(( type != "Certification" && type != "System" && type != "Generic") && tr.getCompletionStatus() != "Success"){
log.error( tr.getName());
}
}
}
Sorry I should have added this in my original post.
I think better approach would be to keep the list of Scheduled tasks you want to monitor in a list or may be in a custom object and then look for completion status as you are change in above code for Success or Error, below are the expected Completion message:
Apologies for late response, if I understood you right you requirement is to flag any Scheduled task which is not of type Certification/Generic/ and System if it fails. Hope below code helps. This is working: