Expand my Community achievements bar.

SOLVED

Issue with suspending and resuming workflows

Avatar

Level 7

When I call workflowSession.suspend() from any step, the workflow gets suspended after completing the whole step(I expected it to suspend right at the point when I called suspend method) and I am not able to resume it again using worfsess.resume(). It stays as it was earlier. When I resume it from console, the status changes to "Running"but it doesnt proceed any further.

 
Has anyone faced something like this?
1 Accepted Solution

Avatar

Correct answer by
Community Advisor

You will need to call workflowsession.complete to take the workflow to the next step. Resuming the workflow doesn't automatically take the workflow to next step. I know that's the weird behavior but that's how workflow resume option behaves.

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/workflow/WorkflowSession.html#complete%28...

Also there is a catch here, if somebody resumes the workflow from UI there it is stuck because when you trigger resume from UI it just doesn't call complete and take workflow to next step, it keeps the workflow on same step with workflow step status as complete. You can validate that from history option of workflow instance.

- Runal

View solution in original post

9 Replies

Avatar

Level 10

did you check the logs what happens when you resume the workflow ?

Avatar

Level 7
Woo.. Thats strange... So do I need to call resume and then complete or just complete.. And workflow completes whole step even if I suspend it in the beginning of step... Is that correct/expected   

Avatar

Level 7
Yes.. I am passing correct I'd. Moreover resuming it from the console also doesn't take it any further.. It just says workflow running with first step completed with no info on next step which is a participant step... And even on suspending it. It continues on to complete that step and then suspends the workflow   

Avatar

Level 7

Nothing... It just doesnt proceed to next step

Avatar

Community Advisor

You can either of the following:

  1. complete and then suspend.
    • Doing so, the workflow item will appear in the inbox of next step participants, though participants wont be able to act on the step as the workflow is in suspended state.
    • session.complete(item, (session.getRoutes(item)).get(0)); session.suspendWorkflow(item.getWorkflow());
  2. resume and then complete.
    • Doing so will only make workflow item appear in inbox of participants in next step, till the point you resume it; it won't appear in the inbox of participants.
    • session.resumeWorkflow(item.getWorkflow()); session.complete(item, (session.getRoutes(item)).get(0));

choose the one that suits your use-case.

Avatar

Correct answer by
Community Advisor

You will need to call workflowsession.complete to take the workflow to the next step. Resuming the workflow doesn't automatically take the workflow to next step. I know that's the weird behavior but that's how workflow resume option behaves.

https://docs.adobe.com/docs/en/cq/5-6-1/javadoc/com/day/cq/workflow/WorkflowSession.html#complete%28...

Also there is a catch here, if somebody resumes the workflow from UI there it is stuck because when you trigger resume from UI it just doesn't call complete and take workflow to next step, it keeps the workflow on same step with workflow step status as complete. You can validate that from history option of workflow instance.

- Runal

Avatar

Level 10

Are you passing the correct Workflow instance to the resumeWorkflow method? Are there any expections being thrown in the code? 

Avatar

Level 7
Thanks.. Will try  that out... Anything about second point: workflow completes whole step even if I suspend it in the beginning of step... Is that correct/expected

Avatar

Community Advisor

That's how it even works from UI workflow console, the step at which you suspend the workflow always gets completed, it won't suspend the current step and re-execute on resume.