03-30-2020 05:13 PM
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.
04-01-2020 04:41 AM
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);
04-01-2020 04:41 AM
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);
04-02-2020 05:41 AM
Hi @upforsin,
Well done for getting it sorted - and thanks for updating your post, really helpful to other users.
Cheers,
Explore our Alfresco products with the links below. Use labels to filter content by product module.