Create Custom Identity Request:
This document should be useful when we build custom workflow and wants to visible in Access Requests also.
It has 2 Simple Steps:
- In Parent Workflow create a step to Initialize Identity Request
- Create a sub workflow to Generate Identity Request
a. step to Create or Initialize Identity Request in parent Workflow
Code Sample:
<Step icon="Task" name="Initialize and Create IR"> <Arg name="appName" value="ref:appName"> <Arg name="IRType" value="Custom Name"/> <Arg name="YourGroupName" value="ref:YourGroupName"/> <Arg name="requesterId" value="ref:requesterId"/> <Arg name="requesterDisplayName" value="ref:requesterDisplayName"/> <Arg name="taskResultId"> <Script> <Source> return wfcontext.getWorkflowcase().getTaskResultId(); </Source> </Script> </Arg> <Return name="idRNum" to="idRNum"/> <Return name="idRId" to="idRId"/> <WorkflowRef> <Reference class="sailpoint.object.Workflow" name="Your Custom Create Identity Request"/> </WorkflowRef> </Step>
b. Now we need to build a Custom Sub-Workflow
``
<?xml version='1.0' encoding='UTF-8'?> The name of the appName. import sailpoint.persistence.Sequencer;
import sailpoint.tools.*;
import java.util.List;
IdentityRequest customIR = new IdentityRequest();
String num = new Sequencer().generateId(context, customIR);
if(num != null) {
customIR.setName(num);
}
customIR.setTargetClass("Your Identity Request Name");
customIR.setSource("UI");
customIR.setTargetDisplayName(YourGroupName);
customIR.setRequesterDisplayName(requesterDisplayName);
customIR.setRequesterId(requesterId);
customIR.setPriority(WorkItem.Level.valueOf("Normal"));
if(taskResultId != null) {
customIR.setTaskResultId(taskResultId);
}
customIR.setType(IRType);
customIR.setExecutionStatus(IdentityRequest.ExecutionStatus.valueOf("Executing"));
customIR.setCompletioStatus(IdentityRequest.CompletionStatus.valueOf("Pending"));
IdentityRequestItem customIRI = new IdentityRequestItem();
customIRI.setApplication(appName);
customIRI.setName("Your IRI Name");
customIRI.setOperation("IRType");
customIRI.setValue(YourGroupName);
customIRI.setProvisioningState(ApprovalItem.ProvisioningState.valueOf("Pending"));
customIRI.setApprovalState(WorkItem.State.valueOf("Pending"));
customIR.add(customIRI);
// Add some more details like requestor comments etc
List l = new ArrayList();
Date date = new Date();
WorkflowSummary.ApprovalSummary yourSummary = new WorkflowSummary.ApprovalSummary();
Comment yourComment = new Comment("Reason for Request :" + reason, requesterDisplayName);
yourComment.setDate(date);
yourSummary.setRequest(IRType + " Request");
yourSummary.addComment(yourComment);
yourSummary.setCompleter(requesterDisplayName);
yourSummary.setStartDate(date);
yourSummary.setEndDate(date);
yourSummary.setOwner(requesterDisplayName);
yourSummary.setState(WorkItem.state.valueOf("Finished"));
l.add(yourSummary);
//if you have autoapproval case then you can add condition Here
customIR.setState("Waiting for Approvals");
customIR.setApprovalSummaries(l);
context.saveObject(customIR);
context.commitTransaction();
workflow.put("stepLastComplete", "Generate IR");
return num;
</Source>
<Transition to="end"/>
</Step>
<Step icon="Stop" name="end"/>
``
Now, You need to update during Approval so In Approval Step: we have to add some steps like
``
IdentityRequest ir = new IdentityRequest();
ir = context.getObjectByName(IdentityRequest.class, idRNum);
if(method.equals(WorkItem.INTERCEPTOR_OPEN_WORK_ITEM)) {
item.setIdentityRequestId(idRNum);
conext.saveObject(item);
customIR.setTaskResultId(wfcontext.getWorkflowcase.getTaskResultId());
context.saveObject(customIR);
conext.commitTransaction();
}
if(method.equals(Workflow.INTERCEPTOR_END_APPROVAL)) {
// Here Update the Identity Request with Reject / Approve Status and comments etc
}
``
Don’t saw this thread yet so thought might be useful who would like to build by custom code.