Calling the workflow from a plugin and workflow should return value back to plugin

Which IIQ version are you inquiring about?

Version 8.3

Share all details related to your problem, including any error messages you may have received.

I have a couple of questions regarding workflow and plugin 1. The workflow should return the response back to the plugin, such as if the workflow is successful and the string value. The plugin should be able to consume the response from the workflow.
String workflowStatus = null;
WorkflowLaunch wflaunch1 = new WorkflowLaunch();
Workflow wf1 = (Workflow)context.getObjectByName(Workflow.class, “workflow_name”);

	    if (wf1 != null) {
	      wflaunch1.setWorkflowName(wf1.getName());
	      wflaunch1.setVariables(launchArgsMap);
	      Workflower workflower1 = new Workflower(context);
	      WorkflowLaunch launch1 = workflower1.launch(wflaunch1);
	      workflowStatus = launch1.getStatus();
	      System.out.println("workflowStatus : " + workflowStatus);
	      TaskResult taskResult1 = launch1.getTaskResult();
	      System.out.println("taskResult : " + taskResult1.toXml());
	      String data1 = (String) wflaunch1.getWorkflowCase().getTaskResult()
	    	        .getAttribute("identityRequestId");
	      System.out.println("data1 : " + data1);
	    } else {
	      System.out.println("Workflow NOT found");
	    }

I’m affraid it’s not that simply possible. The easiest way which came into my mind would be to create rest resource with endpoint which can be called in last step of the workflow to pick up this event.

Second option would be to create a service which periodically would check execution status.

For my better understanding of the ask, can you please provide the below info?

  1. Is the workflow being called from a plugin?
  2. Do you want to execute the plugin code when a workflow is successful?

Ideal way would be to launch workflow via request object and then tracking its completion status in the background and upon completion the result can be leveraged as you have at the end of code to perform other business operation.

As running workflow directly and waiting for it to complete from main thread will unnecessary stall main thread depending upon your system load.

Thanks

You will need to perform all of the functionality inside the actual workflow, including waiting for a sub workflow to complete. A rule (or in this case a piece of Java code) doesn’t wait for the workflow to complete. I will scan my code base to see if there’s a way to do this, but I don’t recall that. Better to put all of the functionality into a Workflow and then have that workflow do all of the work, including calling sub workflows. That’s what workflows are for.

Alternatively you could attempt to query the task result until it completes, but that will chew up a thread until that workflow completes. If any part of that polling goes awry, you will have a stuck thread. I have seen that a lot with people wanting to poll.

Feel free to tell me more about your plugin. I have done a lot of plugin development.

PS Please don’t use System.out.println(). Ever.

Hello @soswain @kjakubiak @ashutosh08 & @Keith_smith , Thanks for your response. I will try to explain the complete use case again. we are trying to implement a business requirement while launching the workflow through SailPoint. For security reasons we are using a plugin in between SailPoint and target/external system. we are sending input variables from plugin to workflow as part of workflow launch. After successful completion of the workflow we are expecting some output/response back to plugin. Please advise how to get output/response from launched workflow back to plugin.

You can define a variable with output = true, and then that should be returned back from your workflow to your rest call to invoke the workflow
in your workflow, and return the expected result in the output variable

<Variable name="outputmessage" output="true"/>

Are you able to resolve it? I am also developing a plugin where I need IdentityRequestId which is defined as output in the workflow but I am not getting it back, so wondering if I am missing something.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.