cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Create a workitem from a rule

Create a workitem from a rule

In a previous discussion (Re: Can a rule or task create workitem?), I have presented an example of how to programmatically, using BeanShell, create a workitem. As the question on how to create or modify a work item is asked fairly often on the forums, I decided to write a blog post about it.

 

<?xml version='1.0' encoding='UTF-8'?>  
<!DOCTYPE Rule PUBLIC "sailpoint.dtd" "sailpoint.dtd"> 
<Rule language="beanshell" name="Create WorkItem"> 
  <Source>import sailpoint.object.*; 
import sailpoint.persistence.Sequencer; 
 
Calendar expiration = Calendar.getInstance(); 
 
Identity targetIdentity = context.getObjectByName(Identity.class, "Amy.Cox"); 
Identity requester = context.getObjectByName(Identity.class, "Aaron.Nichols"); 
 
WorkItem item = new WorkItem(); 
item.setType(WorkItem.Type.ManualAction); 
item.setOwner(context.getObjectByName(Identity.class, "spadmin")); 
item.setRequester(requester); 
Sequencer sequencer = new Sequencer(); 
item.setName(sequencer.generateId(context, item)); 
item.setRenderer("lcmManualActionsRenderer.xhtml"); 
item.setLevel(WorkItem.Level.Normal); 
item.setTarget(targetIdentity); 
item.setTargetClass(Identity.class.getName()); 
item.setDescription("Manual Changes requested for User: "+targetIdentity.getDisplayableName()); 
item.setHandler("sailpoint.api.Workflower"); 
item.setIdentityRequestId("0000000038"); 
 
Attributes attributes = new Attributes(); 
item.setAttributes(attributes); 
 
ApprovalSet approvalSet = new ApprovalSet(); 
ApprovalItem approvalItem = new ApprovalItem(); 
approvalItem.setApplication("DummyThing"); 
approvalItem.setNativeIdentity(targetIdentity.getName()); 
approvalItem.setOperation("Create"); 
approvalItem.setValue("attribuut = \"value\""); 
approvalSet.add(approvalItem); 
 
attributes.put("approvalSet", approvalSet); 
attributes.put("identityDisplayName", targetIdentity.getDisplayableName()); 
attributes.put("identityName", targetIdentity.getName()); 
 
item.setExpiration(expiration.getTime()); 
 
context.startTransaction(); 
context.saveObject(item); 
context.commitTransaction(); 
 
return item; 
</Source> 
</Rule> 

 

This example is a work item for a manual action. It will show the recipient that a change has to be implemented manually. It refers back to an identity request, but does not necessarily need to. If it does refer to a valid identity request, that object will be updated once the request has been completed.

 

Some important attributes of a WorkItem object to be set:

  • The type, so IdentityIQ knows what its purpose is,
  • The renderer: a Java Server Faces page to present the work item,
  • The handler: a class that will handle the result of a work item being completed (and possibly a decision made),
  • The name (a sequential id),
  • Owner (recipient),
  • Requester (person who requested the action to be performed)
  • Description.

 

Different types of work items may have different required attributes and information. Refer to WorkItem objects in your environment, created by example scenarios to figure out what is needed.

Labels (3)
Version history
Revision #:
3 of 3
Last update:
‎May 16, 2026 01:17 PM
Updated by: