Expand my Community achievements bar.

Terminate Workflow in sp12

Avatar

Level 1

Context :
1. AEM is running on sp12 

2. Workflows are not transient and we do not want to convert them to transient since we need the history. 

Problem :  We have a workflow where we need to introduce process step and have below logic in it :

if(custom field is valid){

   proceed with usual flow;

}else{

   terminate/complete the workflow;

}

I have used "wfSession.terminateWorkflow(wfSession.getWorkflow())" to terminate the workflow. Ideally this method should abort the workflow and not retry it. However, in sp12 there seems to be an issue that it retries and then marks it as abort. I found a discussion if workflow is made transient, issue will be resolved. Is there any other solution to close/terminate the workflow other than making it transient in sp12. 
https://github.com/Adobe-Consulting-Services/acs-aem-commons/issues/2879

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Reply

Avatar

Level 8

Hi @ChaithraS 

So just to confirm, the workflow is not marked as transient when it was created:
https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/ext...

Tethich_0-1734642289597.png

Now, based on docs, the complete and terminate operations should archive the workflow instance:
https://experienceleague.adobe.com/en/docs/experience-manager-65/content/implementing/developing/ext...

Have you tried to call complete method and see if the issue still shows ?
https://developer.adobe.com/experience-manager/reference-materials/6-4/javadoc/com/adobe/granite/wor...

If yes, therefore if the issue confirms is in sp12, meaning that is not in your control, what you can do, until it gets fixed, is to try to save the workflow history just before it gets completed/terminated. This can be done using getHistory() method https://developer.adobe.com/experience-manager/reference-materials/6-4/javadoc/com/adobe/granite/wor...