Sunday, February 6, 2022

How to launch workflow using java (API's)?

# Map object to pass as variables to workflow

HashMap launchArgsMap = new HashMap();

launchArgsMap.put(“identityName”,”Prasad”);

launchArgsMap.put(“managerName”,”Santosh”);


# Getting workflow object

Workflow workflow = (Workflow)context.getObjectByName(Workflow.class,"workflowName"); 


# Creating workflowLaunch object

WorkflowLaunch wfLaunch = new WorkflowLaunch(); 

wfLaunch.setWorkflowName(workflow.getName()); 

wfLaunch.setWorkflowRef(workflow.getName()); 

wfLaunch.setCaseName("LCM Provisioning"); 

wfLaunch.setVariables(launchArgsMap); //pass values to workflow 


# Create Workflower and launch workflow from WorkflowLaunch

Workflower workflower = new Workflower(context); 

WorkflowLaunch launch = workflower.launch(wfLaunch); 


Note: 

A class for managing the lifecycle and side effects of Workflows and WorkItems.

For developers outside of SailPoint, the primary methods that should be used are the ones for launching workflows. 

The methods for managing the lifecycle of WorkItems are normally only used by the UI, though it is permissible to finish WorkItems in custom code.


# print workflowCase ID

String workFlowId = launch.getWorkflowCase().getId(); 

System.out.println("workFlowId: "+workFlowId); 

No comments:

Post a Comment

Fetch Members from Workgroup

  import java.util.ArrayList;   import java.util.Iterator;   import java.util.List;   import sailpoint.api.ObjectUtil;   import sailpoint.ob...