cancel
Showing results for 
Search instead for 
Did you mean: 

From Java, starting a workflow with several assignees

nicolasraoul
Star Contributor
Star Contributor
From Java, I can easily start a workflow after having defined its assignee using a HashMap:

workflowProperties.put(WorkflowModel.ASSOC_ASSIGNEE, inviteeNodeRef);

That's good for a workflow that has a mandatory aspect "bpm:assignee".
But my workflow has a mandatory aspect "bpm:assignees". Several assignees.

And unfortunately WorkflowModel.ASSOC_ASSIGNEES does not exist.

How to put the list of assignees into the workflow properties before calling startWorkflow?

Thanks!
1 REPLY 1

nicolasraoul
Star Contributor
Star Contributor
I guessed the solution and tested it, it seems to work as expected:

workflowProps.put(QName.createQName("{http://www.alfresco.org/model/bpm/1.0}assignees"), assignees);

Here is the full code if that can help someone:

// Prepare workflow properties.
NodeRef wfPackage = this.workflowService.createPackage(file);
NodeRef assignee1NodeRef = personService.getPerson(selectedAssignee1);
NodeRef assignee2NodeRef = personService.getPerson(selectedAssignee2);
ArrayList<NodeRef> assignees = new ArrayList<NodeRef>(2);
assignees.add(assignee1NodeRef);
assignees.add(assignee2NodeRef);
Map<QName, Serializable> workflowProps = new HashMap<QName, Serializable>(16);
workflowProps.put(WorkflowModel.ASSOC_PACKAGE, wfPackage);
workflowProps.put(QName.createQName("{http://www.alfresco.org/model/bpm/1.0}assignees"), assignees);

// Get the workflow definition.
WorkflowDefinition workflowDefinition = this.workflowService.getDefinitionByName("jbpm$sawaflow2");

// Start a workflow instance.
WorkflowPath workflowPath = getWorkflowService().startWorkflow(workflowDefinition.getId(), workflowProps);