12-22-2010 11:54 AM
01-06-2011 06:16 AM
var workflow = actions.create("start-workflow");
workflow.parameters.workflowName = "jbpm$wf:serialreview";
workflow.parameters["bpm:workflowDescription"] = "Review for " + document.name;
workflow.parameters["bpm:description"] = "Review process init";
workflow.parameters["bpm:assignee"] = person;
workflow.parameters["initiator"] = people.getPerson("admin");
workflow.execute(document);
if( (workflowDefinition = workflowService.getDefinitionByName("jbpm$wf:serialreview")) != null ) {
// Set workflow parameters
NodeRef workflowNodeRef = workflowService.createPackage(null);
nodeService.addChild(workflowNodeRef, documentNodeRef, ContentModel.ASSOC_CONTAINS, QName.createQName(NamespaceService.CONTENT_MODEL_PREFIX, "Advert within the workflow package"));
parameters.put(WorkflowModel.ASSOC_PACKAGE, workflowNodeRef);
parameters.put(WorkflowModel.ASPECT_WORKFLOW_PACKAGE,workflowNodeRef);
// … Workflow description
parameters.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "Review for " + (String)nodeService.getProperty(documentNodeRef, ContentModel.PROP_NAME));
// … Init task description
parameters.put(WorkflowModel.PROP_DESCRIPTION, "Review process init");
// … Set Workflow initiator as "admin" user
parameters.put(QName.createQName(null, "initiator"), personService.getPerson("admin"));
// Start workflow
WorkflowPath wfPath = workflowService.startWorkflow(workflowDefinition.id, parameters);
// task list
List<WorkflowTask> wfTasks = workflowService.getTasksForWorkflowPath(wfPath.id);
// throw an exception if no tasks where found on the workflow path
if (wfTasks.size() == 0) {
logger.fatal("No workflow StartTask task found");
throw new Exception();
}
try {
WorkflowTask wfStartTask = wfTasks.get(0);
workflowService.endTask(wfStartTask.id, null);
} catch (RuntimeException err) {
logger.fatal("Failed endTask of StartTask task" + err.getMessage());
throw err;
}
}
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.