Workflow failing in the second iteration | Community
Skip to main content
Level 2
October 16, 2015
Solved

Workflow failing in the second iteration

  • October 16, 2015
  • 11 replies
  • 3100 views

ISSUE:

The workflow we require is a multi-approval workflow which means once the author create the content it gets reviewed and approved by 2 roles (First by a Brand Manager and then finally by a Brand Director). The workflow works as expected if both Brand Manager and the Brand Director approves the content in the first go. However in a specific case where the Brand director is rejecting the content the 2nd iteration breaks. Below is the flow which is breaking (Steps to reproduce):

  1. Editor create the content and send it to Brand Manager for approval. (Use any geometrixx page. Put it in the workflow and from the inbox assign it to manager.)
  2. Brand Manager approves it and send it to Brand Director for the final review.
  3. Brand Director rejects the content. (For the rejection process we are using a custom process. The source code for the same is in the attached bundle. We tried using the go to step available with 5.6.1 but it doesn't seems to work.)
  4. The content is now back with the editor with the rejection comment.
  5. The editor changes the content and send it back to the Brand Manager.
  6. The Brand Manager approves the content and send it to the Brand Director for the final approval.
  7. At this step the Brand director is unable to do anything. He is not able to approve/reject the content.

 Package details:

I do have a package which one can use as is to reproduce the issue on a vanilla instance of AEM 5.6.1. However just learned that i cant attach a zip file in this forum. Anyone willing to help me please reply back and i can share the package by any possible way.

Screenshot:

Here is the screenshot of our workflow model.

 [img]acme workflow.PNG[/img]

Appreciate any help in investigating or suggesting if anyone has achieved a similar flow using a different approach.

thanks,
Himanshu

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Himanshu_Pathak

Hi Kish,

Thanks for asking the question. Gives me an opportunity to get this thread to a logical conclusion. Adobe finally provided a hotfix to resolve the issue. The hotfix number is NPR-3850.

You can check the hotfix details at https://helpx.adobe.com/experience-manager/kb/cq561-available-hotfixes.html and request adobe for the same.

thanks,

Himanshu

11 replies

Level 2
October 16, 2015

Hi,

I doubt that this hotfix will work for 5.5 as the issue certainly doesn't exist on 5.5. That said i think you can't use the OOTB goto with 5.5. As far as i remember it never worked for us. the GoTo step of 5.6 on the other hand works just fine. Now since we are on 5.6.1 we are using the OOTB GoTo process. I could find a old reference of this class and providing the same here. You may have to change few things here and there.

 

Cheers,

Himanshu

package com.acme.dmp.core.workflow; import java.util.List; import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Properties; import org.apache.felix.scr.annotations.Property; import org.apache.felix.scr.annotations.Service; import org.osgi.framework.Constants; import com.day.cq.workflow.WorkflowException; import com.day.cq.workflow.WorkflowSession; import com.day.cq.workflow.exec.Route; import com.day.cq.workflow.exec.WorkItem; import com.day.cq.workflow.exec.WorkflowData; import com.day.cq.workflow.exec.WorkflowProcess; import com.day.cq.workflow.metadata.MetaDataMap; /** * * Routes the workflow to specific Route. */ @Component @Service @Properties({ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Go To Specific Step Process."), @Property(name = "process.label", value = "Go To Specific Step Process") }) public class GoToSpecificStepProcess implements WorkflowProcess { /** * JCr_PATH. */ private static final String TYPE_JCR_PATH = "JCR_PATH"; /** * Routes the workflow to specific Route publishing. * * @param item *            the item * @param session *            the session * @param args *            for the args entered by user * * @throws WorkflowException *             the workflow exception */ @Override public final void execute(final WorkItem item, final WorkflowSession session, final MetaDataMap args) throws WorkflowException { final WorkflowData workflowData = item.getWorkflowData(); if (workflowData.getPayloadType().equals(GoToSpecificStepProcess.TYPE_JCR_PATH)) { goToStep(item, session, this.readArgument(args)); } } /** * Read input arguments. * * @param args *            the args * @return the string */ private String readArgument(final MetaDataMap args) { return args.get("PROCESS_ARGS", "false"); } /** * This method is used to get the specific step. * * @param item *            WorkItem * @param session *            WorkflowSession * @param targetRouteName *            step name * @throws WorkflowException *             workflowException * */ public static void goToStep(final WorkItem item, final WorkflowSession session, final String targetRouteName) throws WorkflowException { try { final List<Route> previousSteps = session.getBackRoutes(item); if (previousSteps.isEmpty()) { throw new WorkflowException("No previous steps available."); } Route step = null; step = getStep(targetRouteName, previousSteps, step); if (step != null) { session.complete(item, step); } } catch (final WorkflowException we) { throw new WorkflowException(we); } } /** * This method is used to get the specific step. * * @param targetStepName *            Name of the target step * @param step *            Route * @param previousSteps *            all possible backsteps * @return returns the step * */ private static Route getStep(final String targetStepName, final List<Route> previousSteps, Route step) { if (targetStepName !=null) { step = previousSteps.get(0); } else { for (final Route backStep : previousSteps) { final String routeName = backStep.getName(); if (routeName.equals(targetStepName)) { step = backStep; break; } } } return step; } }