following rule will create a Request object (workflow) to run in future.
import java.util.*;
import java.lang.*;
import java.text.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import sailpoint.api.*;
import sailpoint.object.*;
import sailpoint.workflow.*;
import org.apache.log4j.Logger;
import org.apache.log4j.Level;
import sailpoint.object.Workflow;
import sailpoint.object.Identity;
import sailpoint.object.RequestDefinition;
import java.util.HashMap;
import sailpoint.object.Attributes;
import sailpoint.workflow.StandardWorkflowHandler;
String workflowName = "yaniv post joiner workflow"; // name of the workflow to run (business proccess)
String identityName = "Alan.Bradley";
String argumentVal = "CN=john.doe,DC=corp,DC=acme,DC=com"; // example of argument pass to workflow, create any workflow variabled you need and pass them in the wfArgs
String caseName = "Run '" + workflowName + "' for: " + identityName; // give it a good name, see below picture
String requesterId = "Alan.Bradley"; // the event will be shown on Events tab on the identity who is set here
Workflow eventWorkflow = context.getObject(Workflow.class, workflowName);
// check workflow name exists
if (null == eventWorkflow) {
log.error("Could not find a workflow named: " + workflowName);
throw new GeneralException("Invalid worklfow: " + workflowName);
}
// Simulate the request being submitted by a user. Default: spadmin. - set requestor details
Identity id = context.getObjectByName(Identity.class, requesterId);
if (null == id) {
log.error("Could not find a requester Identity: " + requesterId);
throw new GeneralException("Invalid identity: " + requesterId);
}
// Ask the Request Processor to start the workflow 5 seconds from now.
// Append the time stamp to the workflow case name to ensure it's unique.
long launchTime = System.currentTimeMillis() + 60000;
caseName = caseName + "(" + launchTime + ")";
// Build out a map of arguments to pass to the Request Scheduler.
Attributes reqArgs = new Attributes();
reqArgs.put(StandardWorkflowHandler.ARG_REQUEST_DEFINITION,sailpoint.request.WorkflowRequestExecutor.DEFINITION_NAME);
reqArgs.put(sailpoint.workflow.StandardWorkflowHandler.ARG_WORKFLOW,workflowName);
reqArgs.put(sailpoint.workflow.StandardWorkflowHandler.ARG_REQUEST_NAME,caseName);
reqArgs.put( "requestName", caseName );
// Build a map of arguments to pass to the Workflow case when it launches.
Attributes wfArgs = new Attributes();
wfArgs.put("identityName",identityName);
wfArgs.put("exampleArgument", argumentVal);
wfArgs.put("workflow",eventWorkflow.getId());
reqArgs.putAll(wfArgs);
// Use the Request Launcher to schedule the workflow reqeust. This requires
// a Request object to store the properties of the request item.
Request req = new Request();
RequestDefinition reqdef = context.getObject(RequestDefinition.class, "Workflow Request");
req.setDefinition(reqdef);
req.setEventDate( new Date( launchTime ) );
req.setOwner(id);
req.setName(caseName);
req.setAttributes( reqdef, reqArgs );
// Schedule the work flow via the request manager.
RequestManager.addRequest(context, req);
the event is goind to be visible in the Events tab of the identity - suggest to use summary to present what is the event doing