Need to auto-schedule and auto-generate reports before and after the certification

Hi All,

I hope everyone is doing well. We are seeking advice on how to implement the following automated process:

Auto-schedule and Auto-generate OOTB (Out-of-the-Box) reports before and after the certification.

Below are the Reports:

Pre-Reports:
• Users by Application Report
• Role Members Report (if an application has more than ten roles contact the IAM team)
• Identity Entitlements Detail Report (to identify the managers are under review)
• Role Profiles Composition Report - Extended

Post-reports:
• Certification Consolidated Live Report - Certification name(Certification Group)
• Revocation Live Report - Certification name(Certification Group)
• Role Profiles Composition Report
• Role Members Report

Note: Currently, as part of our certification event process, we manually generate 4 OOTB reports before and after each certification.
now, we have a requirement to automate these steps. Please advise on how we can achieve this and provide any reference code if available.

Specifically, we need guidance on:

How to automatically schedule and generate the required OOTB reports.
We tried it using rule But getting error while Auto-generating it.

Below is piece of code for reference :

import sailpoint.api.SailPointContext;
import sailpoint.object.TaskDefinition;
import sailpoint.object.TaskSchedule;
import sailpoint.object.Attributes;
import sailpoint.tools.GeneralException;
import java.util.Date;
import org.apache.log4j.Logger;
import sailpoint.api.TaskManager;
import org.apache.commons.lang3.time.DateUtils;
import java.util.UUID;

log.info(“Starting Report Generation”);

String status = “SUCCESS”;

// — Report 1: Example - “Users by Application Report” Report —
String report1Name = “Users by Application Report”;
String report1OutputName = “Users by Application Report_” + UUID.randomUUID().toString();

try {
TaskDefinition report1Def = context.getObject(TaskDefinition.class, report1Name);
if (report1Def == null) {
log.error(“TaskDefinition for report '” + report1Name + “’ not found.”);
status = “FAILED - Users by Application Report not found”;
} else {
TaskSchedule report1Schedule = new TaskSchedule();
report1Schedule.setName(report1OutputName);
report1Schedule.setDescription(“Users by Application Report”);
report1Schedule.setTaskDefinition(report1Def);
report1Schedule.setLauncher(“spadmin”);

  Attributes report1Args = new Attributes();
  report1Args.put("reportTitle", "Users by Application Report");
  report1Args.put("outputFormat", "CSV");
  report1Args.put("application", "Asia SIS Life Imaging System (Hong Kong)");
  report1Args.put("startDate", DateUtils.addDays(new Date(), -30));
  report1Args.put("endDate", new Date());



  report1Schedule.setArguments(report1Args);



  context.saveObject(report1Schedule);



  Date now = new Date();
  report1Schedule.setNextExecution(now);



  TaskManager tm = new TaskManager(context);
  tm.runNow(report1Schedule);



  context.commitTransaction();



  log.info("Report '" + report1Name + "' generation task started successfully with name: " + report1OutputName);
  status = "SUCCESS - Report generation task started for: " + report1OutputName;
}

} catch (Exception e) {
log.error(“Error generating report '” + report1Name + "': " + e.getMessage(), e);
status = "FAILED - Report 1 Error: " + e.getMessage();
e.printStackTrace();
}

return status;

Note : Please advise on this.

Regards,
VU

@Venu1010 pls check these thread

Solved: Running a custom report from a rule - Compass

Running a task from a rule or workflow - Compass

let me know if that works

it should work for OOB as example attached in above.

//Run Report

//String certActReportName = "Certification Activity by Application Report ";(Standard Report)
String certActReportName = "Certification Activity by Application Report_New";(custom report where we added few more fields)
String certActReportTaskDefId = context.getObjectByName(TaskDefinition.class, certActReportName).getId();


Map reportArgs = new HashMap();
reportArgs.put("application", appId);
reportArgs.put("creationDateStart", certobj.getCreated());
reportArgs.put("emailIdentities", Util.listToCsv(ids));                                           
TaskManager tm = new TaskManager(context);
System.out.println("before running the report");
TaskResult tr = tm.runSync(certActReportTaskDefId, reportArgs);

Hi VU,

Based on SailPoint’s guidance, you don’t need to create and persist a TaskSchedule inside your rule. The recommended approach is to call the TaskManager methods directly. For your use case (auto-generating OOTB reports before/after certifications), you can use either run() or runSync() depending on whether you want to wait for the result.

Example (simple on-demand report run):

try {
  TaskManager tm = new TaskManager(context);
  Attributes<String,Object> args = new Attributes<>();
  args.put("reportTitle", "Users by Application Report");
  args.put("outputFormat", "CSV");

  // Run immediately, result handled asynchronously
  tm.run("Users by Application Report", args);

  // If you want to wait until it completes:
  // TaskResult result = tm.runSync("Users by Application Report", args);

  log.info("Report triggered successfully.");
} catch (Exception e) {
  log.error("Error running report: " + e.getMessage(), e);
}

  • Use TaskManager.run() for fire-and-forget execution.

  • Use TaskManager.runSync() if you need the result in the same thread.

  • Only use runNow() with a TaskSchedule if you really want to reuse an existing schedule.

This way you can call your list of pre- and post-certification reports from the workflow rule without the scheduling errors you were seeing.