VMware Cloud Community
rreghuram
VMware Employee
VMware Employee

regarding getting the output parameter values of workflow through javascript

I am in need of execute a workflow in an action and retrieve an output parameter which contains a list of string.

It will be of great help if some one could throw some light

Thanks in advance

Reghu

0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee

It will look like this:

var workflowToLaunch = Server.getWorkflowWithId("608080808080808080808080808080804C828080013141141566711a974a8fef8");

if (workflowToLaunch == null) {
    throw "Workflow not found";
}

var workflowParameters = new Properties();
workflowParameters.put("inputParameter1Name", inputParameter1Value);
workflowParameters.put("inputParameter2Name", inputParameter2Value);

var wfToken = workflowToLaunch.execute(workflowParameters);

while (wfToken.state == "running" || wfToken.state == "waiting" && wfToken.state == "waiting-signal") {
    System.sleep(5000);
}       
if (wfToken.state == "failed") throw wfToken.exception;
var outputParameters = wfToken.getOutputParameters();
var outputParameter = outputParameters.get("outputPutParameter1Name");

You can get a workflow ID soing a System.log(wf.id); (using a wf attribute)

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos
cdecanini_
VMware Employee
VMware Employee

BTW running a workflow and getting its output from an action is quite unusual. It is a lot easier to do it from a workflow.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
0 Kudos