AnsweredAssumed Answered

how to manage workflows programmatically?

Question asked by wps07032 on Jan 7, 2008
Latest reply on Jan 11, 2008 by davidc
Hi all,

Can someone shed some lights on how to manage (create, start, delete, get status and etc) workflows programmatically?  For instance, how to kick off the default "Review and Approval" workflow by using the Java API?  I've seen a code snippet in this forum which suggested to use "workflowService".  But how to create a new instance of it?

// Get a list of workflow definitions and search through them for the one we want.
// Not sure if this is the best way to do this, but it seems to work.
List<WorkflowDefinition> workflowDefs = workflowService.getDefinitions();
Iterator<WorkflowDefinition> workflowDefsIterator = workflowDefs.iterator();
WorkflowDefinition workflowDef = null;

// Get a handle to the required workflow.
while (workflowDefsIterator.hasNext()) {
   workflowDef = workflowDefsIterator.next();

   if (workflowDef.name.equals(JBPM_WORKFLOW_NAME)) {
      break;
   }
}

Thanks.

Outcomes