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

Launching a workflow using code

Launching a workflow using code

It's possible to launch a workflow from within BeanShell/Java. See below for the syntax to launch a workflow using the API.

 

Set any workflow variables that you'd like to set in your launchArgsMap and run the workflow.

import java.util.HashMap;

import sailpoint.api.sailpointContext;

import sailpoint.api.Workflower;

import sailpoint.object.Workflow;

import sailpoint.object.WorkflowLaunch;





// Create and set workflow variables. These are passed into the workflow.



HashMap launchArgsMap = new HashMap();

launchArgsMap.put("myvariable","myvalue");





// Find our workflow... replace MyWorkflow with yours



Workflow wf = (Workflow)context.getObjectByName(Workflow.class,"MyWorkflow");



// Create and Configure WorkflowLaunch object



WorkflowLaunch wflaunch = new WorkflowLaunch();

wflaunch.setWorkflowName(wf.getName());

wflaunch.setWorkflowRef(wf.getName());

wflaunch.setCaseName("MyWorkflowCaseInstance");

wflaunch.setVariables(launchArgsMap);



//Create Workflower and launch workflow from WorkflowLaunch



Workflower workflower = new Workflower(context);

WorkflowLaunch launch = workflower.launch(wflaunch);

 

Labels (1)
Comments

In line # 23 what does setCaseName(); method mean?

It set's the name of the workflow case.

Thank you Chris

I think I'm missing something here.  It looks like, after you've retrieved Workflow wf on line 16, you only use it to extract names.  Is that correct?  Also, you've created two distinct instances of WorkflowLaunch, one on line 20 that you fill out in the next several lines and then pass to the Workflower.launch() method on line 29, and a second that is returned by that method.  I'm only asking because that all looks kind of odd to me.

To answer your questions, I figured I'd break down the code for you....

The WorkflowLaunch object wflaunch is used to set all the launch parameters in order to call the launch() method later. This includes input variables that are passed into the workflow when it's launched and also the name of the workflowcase as it will appear while it's running (in the task results view and in the debug page or in the IIQ console.)

We set the name and the reference for the wflaunch object to the name of the workflow that we want to launch.

Later we call the method launch(wflaunch) in order to take the information in the wflaunch object and kick off the workflow.

The saving of the wflaunch object from the call to launch(wflaunch) is not required as you have a handle to the wflaunch object from the code above so is not necessary but it doesn't create a new object. It's just going to be another reference to the same wflaunch object.

Chris,  I think I was confused because I could not find the Javadoc for the Workflower object.  It doesn't appear in the Javadoc I have from the initial 7.0 release.  I was able to figure it out by digging through the identityiq.jar file in eclipse and reading the method parameters and return values published for that class.

Thanks for your reply.

Hi All,

Can someone please explain how we can add or modify the approval scheme for the workflow being called.  I have already tried setting approvalScheme and approvingIdentities arguments to wflaunch, with no luck.

Thanks in advance.

Yadu

 

Hello experts, 

Even though this is a relatively old post. May I ask what's the difference between WorkflowLaunch and RequestManager in terms of launching workflow? 

 

Hello Experts,

How can we validate SOD's while launching the WF's. Its (Workflower) allowing to request conflict roles where policyScheme set as Interactive. Is there any method available to provide this information before it actually submits the request ?  

Version history
Revision #:
2 of 2
Last update:
‎Jul 27, 2023 11:52 PM
Updated by: