cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve all the completed workflows of a document using Javascript

giangkt
Champ in-the-making
Champ in-the-making
Hi there!

I'd like to get all the completed workflows of a document to help my client's boss to track all the activities of his team.

I think using Node Script is so great but it only supports to get ActiveWorkflows but not AllWorkflows.

Please give me a glue.

Giang.
3 REPLIES 3

mitpatoliya
Star Collaborator
Star Collaborator
You specifically wanted to use javascript only?
Because in java you will be able to get that easily through

API's of WorkflowService

public List<WorkflowInstance> getWorkflowsForContent(NodeRef packageItem, boolean active);

You just need to pass the noderef of the content and "active" flag as false It will return all the completed workflow

giangkt
Champ in-the-making
Champ in-the-making
Thanks Mits,

I'm considering to use Java webscript to achieve this. Giang.

michaelböckling
Champ in-the-making
Champ in-the-making
Hi Giang,

you can use a little trickery to achieve this, if your script is from a secure location (not stored in the repo). Here goes:



var field = Packages.org.springframework.util.ReflectionUtils.findField(userhome.getClass(), "services");
field.setAccessible(true);
var services = Packages.org.springframework.util.ReflectionUtils.getField(field, userhome);
var workflowService = services.getWorkflowService();

var completedWorkflows = workflowService.getWorkflowsForContent(yourScriptNode.getNodeRef(), false);



Cheers,
Michael