PRVS
PRVS

Reputation: 1690

Share file of a workflow with assignees - Alfresco

I'm making a custom workflow, and I want to share the file that I create a workflow with the assignees, because otherwise, the users only access the file through "I've recently modified" and when the task is done, the file disappears.

How can I share the file when I create the workflow with assignees?

Thanks in advance.

Upvotes: 1

Views: 117

Answers (1)

Stefan De Laet
Stefan De Laet

Reputation: 1419

Use a executionflowlistener on start of workflow that gets the nodes in your workflowpackage and then adds the "user home" noderef as a secondary parent.

Get workflow package nodes :

 ActivitiScriptNode packageItemsbpm = (ActivitiScriptNode) execution.getVariable(BPM_PACKAGE);
List<ChildAssociationRef> packageitemAssociations =  nodeService.getChildAssocs(packageItemsbpm.getNodeRef()); 

Then iterate these wf package nodes, and add them to the assignees home folders:

for(String assigneeName : assigneesList) {
    ResultSet rs = getServiceRegistry().getSearchService().query(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, SearchService.LANGUAGE_LUCENE, "PATH:\"/app:company_home/app:user_homes/cm:"+ assigneeName  +"\"");
    if(rs.length() > 0){
          NodeRef assigneeHome = rs.getNodeRef(0);                                        
          nodeService.addChild(assigneeHome, nodeRef, ContentModel.ASSOC_CONTAINS, nodeService.getPrimaryParent(nodeRef).getQName());
    }
 }

Upvotes: 1

Related Questions