Yes, but you have to retrieve the workflow object somehow. There are plenty of ways to do that from statically defining it or looking it up by name or uuid etc. It has a .execute() method. You'll need to pass it in a properties type set correctly for each input needed to run the workflow.
1 person found this helpful
The whole process can be summarised as below:
1) Get the workflow ID for the workflow you want to run. You can get it either in code or copy it from GUI ->General Tab-> ID.
2)Use an inbuilt library action to get the WF Object.
var wfObject = System.getModule("com.vmware.library.workflow").getWorkflowById("<WF ID>");
3) Input Parameters are passed as properties:
var workflowParameters = new Properties();
workflowParameters.put("<InputParameter Name>", <value>);
4) Execute the workflow with properties as input parameters.
var token = wfObject.execute(workflowParameters);
5) Wait for the workflow to complete. You can use an inbuilt library action for that.
6) Log if you want:
System.debug("Workflow: " + token.name + "State: " + token.state);