Which IIQ version are you inquiring about?
Version 8.3
Share all details related to your problem, including any error messages you may have received.
How can I get all scheduled tasks that have already run in task results via rule? I want information like how much time it takes to execute and also the result of a scheduled task, like whether it failed or was completed.
iamksatish
(Satish Kurasala)
May 8, 2024, 5:06pm
2
@amanKsingh
You can TaskSchedule API to get the details you needed.
Below are methods you have to use for the information you were requesting
getDefinitionName - Gives the corresponding Task Definition that is scheduled
getLatestResultStatus - Gives the latest run task result status
getLastExecution() - Gives the date of last execution time
From getLatestResult you will get TaskResult Object which can be used to find the start and end time of latest execution which gives you the duration of execution.
venus
(Venugopala Rao Sarika)
May 8, 2024, 5:15pm
3
I have similar needs but not completed ones. I have changed my code little bit to pull finsihed tasks but I have not tested the changes though.
public void getFinishedTasks() throws GeneralException {
Filter finishedTaskResults = Filter.notnull("completionStatus");
QueryOptions qo = new QueryOptions();
qo.setOrderBy("name");
qo.addFilter(finishedTaskResults);
Iterator<TaskResult> taskResultItr = context.search(TaskResult.class, qo );
}
iamksatish
(Satish Kurasala)
May 8, 2024, 5:31pm
4
@amanKsingh
try this code, this will give the task schedule and corresponding details
You can enhance this based on your requirement
import java.util.ArrayList;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Iterator;
import sailpoint.object.TaskResult;
import sailpoint.object.TaskDefinition;
import sailpoint.object.TaskSchedule;
import sailpoint.object.TaskResult.CompletionStatus;
import sailpoint.object.QueryOptions;
import sailpoint.object.Filter;
QueryOptions qo=new QueryOptions();
qo.addFilter(Filter.notnull("id"));
List taskScheduleList = context.getObjects(TaskSchedule.class,qo);
Map taskScheduleOutput=new HashMap();
for(TaskSchedule taskSchedule: taskScheduleList){
String taskScheduleName=taskSchedule.getName();
String defintionName=taskSchedule.getDefinitionName();
Date lastExecutionTime=taskSchedule.getLastExecution();
String lastExecDate="";
if(lastExecutionTime!=null)
{
SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");
lastExecDate = formatter.format(lastExecutionTime);
}
TaskResult taskResultObj=taskSchedule.getLatestResult();
String lastRunStatus="";
int lastRunTime=0;
String lastRunTimeStr="";
if(taskResultObj!=null){
lastRunTime=taskResultObj.getRunLength();
lastRunStatus=taskResultObj.getCompletionStatus().toString();
}
if(lastRunTime!=0){
lastRunTimeStr= lastRunTime.toString();
}
Map taskResultMap=new HashMap();
taskResultMap.put("task Defintion Name",defintionName);
taskResultMap.put("Last Execution Time",lastExecDate);
taskResultMap.put("Last Execution Status",lastRunStatus);
taskResultMap.put("Last Execution Duration",lastRunTimeStr);
taskScheduleOutput.put(taskScheduleName,taskResultMap);
}
return taskScheduleOutput;
1 Like
system
(system)
Closed
July 7, 2024, 5:31pm
5
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.