Expand my Community achievements bar.

SOLVED

Need help in programmatically advance to next step in CQ 5.5 workflow process step

Avatar

Level 2

Below is the code I am using to programmatically move to next workflow step i.e. auto handler advance programmatically instead of selecting the checkbox auto handler advance on the step.

List<Route> routes = workflowSession.getRoutes(workItem); if(CollectionUtils.isNotEmpty(routes)) { for (Route route : routes) { logger.info("Route: " + route.getName() + " route: " + route); } workflowSession.complete(workItem, routes.get(0)); }

Although the logger gives me the right route information I am not able to proceed to the next step and the workflow goes on running state.

References used for the above code:

API Reference

Similar Question

Kindly let me know what am I missing. Let me know if you need more details and will update the question.

1 Accepted Solution

Avatar

Correct answer by
Level 10

Make sure to get active work item

WorkItem newWorkItem = wfsession.getActiveWorkItems()[0];
wfsession.complete(newWorkItem, wfsession.getRoutes(newWorkItem).get(0));

View solution in original post

3 Replies

Avatar

Correct answer by
Level 10

Make sure to get active work item

WorkItem newWorkItem = wfsession.getActiveWorkItems()[0];
wfsession.complete(newWorkItem, wfsession.getRoutes(newWorkItem).get(0));

Avatar

Level 5

u have to make a refreence of workitem

new Workitem

and assign it to this

complete(new WorkItem item, Route routeofnextWorkflow) 

Avatar

Level 10

This should advance to the next step:

// completing or advancing to the next step
wfSession.complete(workItem, routes.get(0));

See the Javadoc:

https://docs.adobe.com/docs/en/cq/5-5/javadoc/com/day/cq/workflow/WorkflowSession.html