How to assign a task based on NodeRef ?

cancel
Showing results for 
Search instead for 
Did you mean: 
upforsin
Senior Member

How to assign a task based on NodeRef ?

Jump to solution

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 Solution

Accepted Solutions
upforsin
Senior Member

Re: How to assign a task based on NodeRef ?

Jump 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);  

 

howkymike
Alfresco Developer

View solution in original post

2 Replies
upforsin
Senior Member

Re: How to assign a task based on NodeRef ?

Jump 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);  

 

howkymike
Alfresco Developer
EddieMay
Alfresco Employee

Re: How to assign a task based on NodeRef ?

Jump to solution

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!