I modified my code as per your instruction, but this fails with error"workflow was executed with 'name' input set tonull", pasted code below for your reference. Can you share me full working sample code?
WorkflowService workflowService = new WorkflowService(session);
ExecutionService executionService = new ExecutionService(session);
//find a workflow by ID
Workflow workflow = workflowService.getWorkflow("e6820263-366a-487c-be29-1cxdc23db7e5"); //Workflowname "Power off virtual machine and wait"
SdkObject obj = new SdkObject();
obj.setType("VC:VirtualMachine"); // param type, in the form <pluginname>:<typename>
obj.setId("VCIP/vm-1841"); // the ID of the virtual machine in the form <VCip>/<objectid>
obj.setDisplayValue("testVMVCO1");
ExecutionContext context = new ExecutionContextBuilder().addParam("vm",obj).build();
//run the workflow
WorkflowExecution execution = executionService.execute(workflow, context);
execution = executionService.awaitState(execution, 500, 10, WorkflowExecutionState.CANCELED, WorkflowExecutionState.FAILED, WorkflowExecutionState.COMPLETED);
String nameParamValue = new ParameterExtractor().fromTheOutputOf(execution).extractString("name");
System.out.println("workflow was executed with 'name' input set to" + nameParamValue);
//wait for the workflow to reach the user interaction state, checking every 500 milliseconds
//execution = executionService.awaitState(execution, 500, 10, WorkflowExecutionState.CANCELED, WorkflowExecutionState.FAILED, WorkflowExecutionState.COMPLETED);
//String nameParamValue = new ParameterExtractor().fromTheOutputOf(execution).extractString("name");
//System.out.println("workflow was executed with 'name' input set to"+nameParamValue);
}
catch(Exception e)
{
System.out.println(e);
}
}