How to accomplish a Workflow Step Back in AEM

How-to-accomplish-a-Workflow-Step-Back-in-AEM_v4
A question came into the blog a while back asking for some help about Adobe Experience Manager workflows. We recommended that the person look into our articles about workflows that we had done in the past. However, he was having some trouble (possibly because the documentation he was referring to was from CQ5.4 and Adobe documentation is sometimes a little sparse). Here is what he sent to us:

“I created a Workflow, using documentation from this URL: http://blogs.adobe.com/learningwem/2011/11/30/cq5-4-workflow-example-approve-reject-by-the-reviewer/. I created two users: auth (Author) and app (Approver) with some ACLs. I logged in as auth, created a page, authored it, and triggered the workflow to activate it. I then logged in as app and saw the task in the Inbox. I am able to complete the task and the page will be published. But when I selected ‘Step Back’ button, it displays ‘There are no items that can step back.’”

The workflow has only one step; Reviewer. But if reviewer finds faults, how do you step back? Should it not go to workflow initiator, who is the author?”

Since this may not be expressly stated anywhere, let us state it now. You can’t step back a workflow process if there is only one step in the workflow. Stepping back moves the payload from one step to the previous step—so you can’t step back if you are in the first step of a workflow process. Stepping back can’t terminate the workflow.

One solution would be to add another step before the approval step called review, which would require the author to review his work before moving the payload into the approval step. The author would trigger this workflow and then move the page into the approval step. It would be a two-step process for the author, so the approver could step back the workflow to the author.

The disadvantage to this approach is that the workflow has only one outcome, which is publication. In order for the content in question to be completely denied for publication, the author has to terminate the workflow. Documentation on terminating workflows can be found here: https://docs.adobe.com/docs/en/aem/6-1/administer/operations/workflows/wf-admin.html.

My recommendation would be to use Step Back as an exception rather than part of the standard workflow process. My reason for this is because it defeats the principle and concept of having a workflow process.

A preferred solution would be to put an OR split in the workflow that would allow the approver to choose either approve or reject. Approval would be an automated step that would automatically publish the content. The reject step could be an automated step that would simply end the workflow by doing no action, or it could be a user step that would notify the initiator (in this case the author) that the content was rejected.

Screen Shot 2016-05-24 at 11.25.42 AM

The main advantage to this approach is that the workflow always has an endpoint that will complete the workflow. Having workflows remain in limbo can sometimes cause confusion if they are constantly being bounced back and forth between approval and review.

Another advantage to this approach is in the notification step that can be added in the rejection branch that notifies the author about the rejection. This step can be used to give the author feedback as to why the content was rejected and what needs to be changed. Some people have chosen to use comments in the workflow step to convey such information.

I also strongly recommend reading the AEM 5.6.1 workflow documentation since it contains more updated information, especially for this use case.

https://docs.adobe.com/docs/en/cq/5-6-1/workflows/create-models.html#Defining%20a%20Rule%20for%20an%20OR%20Split
OR
https://docs.adobe.com/docs/en/cq/5-6-1/workflows/wf-overview.html

If you are using a more updated version of AEM, then I suggest reading the most updated documentation here for AEM 6.2.

We hope this helps any of you who run into a similar problem setting up a workflow. If you have any other ideas about how to handle this, then feel free to share it with us and we will update this blog post. Send the ideas to [email protected]