cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign a task based on NodeRef ?

upforsin
Star Collaborator
Star Collaborator

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.

howkymike
Alfresco Developer
1 ACCEPTED ANSWER

upforsin
Star Collaborator
Star Collaborator

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);  
howkymike
Alfresco Developer

View answer in original post

2 REPLIES 2

upforsin
Star Collaborator
Star Collaborator

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);  
howkymike
Alfresco Developer

EddieMay
World-Class Innovator
World-Class Innovator

Hi @upforsin,

Well done for getting it sorted - and thanks for updating your post, really helpful to other users.

Cheers, 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!