Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

How to rollback/goto any previous step in custom workflow model programatically? [AEM6.4]

Avatar

Level 2

Hi,

I'm using AEM6.4 for this project and there's a scenario in the Workflow where on the particular condition I need to 'Go back to one of the previous workflow steps?'

Say(refer image below): When the action fails on 'Step D' the control/workflow must be set again to 'Step A' and start again from that step.

I'm new to AEM & not sure if that's even possible but that's what is the requirement?

I saw a brief note on 'GoTo' statements for AEM 6.4 documentation on workflows but that's it just 2-3 lines about it. (not very helpful)

But unfortunately couldn't find any reference doc or example regarding the same.

1625813_pastedImage_0.png

Or in other words:

There's already Rollback(to any previous workflow step) functionality available in AEM (AEM6.4 atleast) via UI whenever a workflow step fails (refer image below). I just want to achieve this programmatically within the custom workflow process class.

Any help regarding this is appreciated.

-Thanks

1626238_pastedImage_4.png

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

You can add Goto Step there you can choose programatically where control should go after notify again step.

Workflow Step Reference



Arun Patidar

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Hi,

You can add Goto Step there you can choose programatically where control should go after notify again step.

Workflow Step Reference



Arun Patidar

Avatar

Community Advisor

Hello,

 

You can use the Route API to advance the Workflow in variable available directions.

To fetch all available Routes use:  

 

List<Route> routes = workflowSession.getRoutes(workItem, false);

Then based on name/id of the route, you can advance the workflow

 


Aanchal Sikka