I want to create an action which uses authority.ftl to pick a user and start a workflow.
How Can I create a simple pooled workflow and assign workflow task to this picked user?
So far, I have this code:
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
if (serviceRegistry.getNodeService().exists(actionedUponNodeRef) == true) {
String assocString = (String) action.getParameterValue(PARAM_MY_ASSOC);
NodeRef nodePersonUser = new NodeRef(assocString);
PersonInfo pi = serviceRegistry.getPersonService().getPerson(nodePersonUser);
String username = pi.getFirstName();
Map<QName, Serializable> properties = new HashMap<QName, Serializable>();
WorkflowService workflowService = serviceRegistry.getWorkflowService();
properties.put(WorkflowModel.ASSOC_ASSIGNEE, nodePersonUser);
Serializable wfPackage = workflowService.createPackage(actionedUponNodeRef);
properties.put(WorkflowModel.ASSOC_PACKAGE, wfPackage);
properties.put(WorkflowModel.PROP_WORKFLOW_DESCRIPTION, "My action workflow");
WorkflowDefinition reviewDef = workflowService.getDefinitionByName("activiti$activitiReview");
workflowService.startWorkflow(reviewDef.getId(), properties)
}
There are no errors but there are also no items in the workflow tasks.
Solved! Go to Solution.
I got it. It didn't work because the assignee didn't have permission to see that particular file.
That line of code solves the problem:
serviceRegistry.getPermissionService().setPermission(actionedUponNodeRef, p.getUserName(), serviceRegistry.getPermissionService().COORDINATOR, true);
I got it. It didn't work because the assignee didn't have permission to see that particular file.
That line of code solves the problem:
serviceRegistry.getPermissionService().setPermission(actionedUponNodeRef, p.getUserName(), serviceRegistry.getPermissionService().COORDINATOR, true);
Hi @upforsin,
Well done for getting it sorted - and thanks for updating your post, really helpful to other users.
Cheers,
Ask for and offer help to other Alfresco Process Services and Activiti Users and members of the Alfresco team.
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.