gizmo16
gizmo16

Reputation: 113

Alfresco - add item to existing workflow

I need help with update workflowTask, add file to existing workflow.

My code is:

    List<NodeRef> addNodes = new ArrayList<NodeRef>();
    addNodes.add(addNodeRef);

    Map<QName, List<NodeRef>> nodesAdd = new HashMap<QName, List<NodeRef>>();
    nodesAdd.put(WorkflowModel.ASSOC_PACKAGE, addNodes);


    workflowService.updateTask(currentTask.getId(), null, nodesAdd, null);  //nullpointer

Is there any other way an item is added to the already running workflow?

Where's my mistake?

Thanks in advance

Upvotes: 1

Views: 700

Answers (1)

Andreas Steffan
Andreas Steffan

Reputation: 6169

You have to add children to the package. Like this:

NodeRef packageNodeRef = ((ActivitiScriptNode)variables.get(bpm_package")).getNodeRef();
QName qname  = nodeService.getPrimaryParent(toAddNodeRef).getQName();
QName assocTypeQName = WorkflowModel.ASSOC_PACKAGE_CONTAINS;
nodeService.addChild(packageNodeRef, toAddNodeRef, assocTypeQName, qname);

Upvotes: 5

Related Questions