views:

71

answers:

2

Hello,

I'm trying to get a list of workflows the document is attached to in an Alfresco webscript, but I am kind of stuck.

My original problem is that I have a list of files, and the current user may have workflows assigned to him with these documents. So, now I want to create a webscript that will look in a folder, take all the documents there, and assemble a list of documents together with task references, if there are any for the current user.

I know about the "workflow" object that gives me the list of workflows for the current user, but this is not a solution for my problem.

So, can I get a list of workflows a specific document is attached to?

+1  A: 

Unfortunately the javascript API doesn't expose all the workflow functions. It look like getting the list of workflow instances that are attached to a document only works in Java (or Java backed webscripts).

List<WorkflowInstance> workflows = workflowService.getWorkflowsForContent(node.getNodeRef(), true);

A usage of this can be found in the workflow list in the document details: http://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/web-client/source/java/org/alfresco/web/ui/repo/component/UINodeWorkflowInfo.java

To get to the users who have tasks assigned you would then need to use getWorkflowPaths and getTasksForWorkflowPath mehtods of the WorkflowService.

Florian
Well, that does answer my question :(Anyway, I made the workaround and I doubt I'll have the time recently to come back to this and rewrite it in Java.
zladuric
+2  A: 

Well, for future reference, I've found a way to get all the active workflows on a document from javascript:

var nodeR = search.findNode('workspace://SpacesStore/'+doc.nodeRef);
    for each ( wf in nodeR.activeWorkflows )
    { 
        // Do whatever here.
    }
zladuric