Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

Workflow is still running even after step showing as completed.

Avatar

Adobe Champion

Workflow steps show completed. But still it is showing as 'Running' in the workflow instances?

Tried adding the step as in this post - https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/custom-workflow-instance-a... , added dam update workflow step as last step, still this is not fixed.

P_V_Nair_0-1671112747782.png

 

Please find below the code from my workflow

 

@component(name = "TestMove operation", service = WorkflowProcess.class, property = {
"process.label=Move operation" })
public class MoveOperation extends GenericWorkflowProcess {

@reference
private ResourceResolverFactory resourceResolverFactory;

@reference
private TestService service;

@Override
public void execute(WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap)
throws WorkflowException {
final WorkflowData workflowData = workItem.getWorkflowData();
final String assetPath = workflowData.getPayload().toString();
try (ResourceResolver resolver = resourceResolverFactory
.getServiceResourceResolver(ServiceUser.SERVICE_USER.getAuthMap())) {
Long serialValue;
Resource resource = resolver.getResource(assetPath);
Resource metadataResource = resource.getChild(Constants.JCR_CONTENT_METADATA_WITHOUT_SLASH);
ValueMap properties = ResourceUtil.getValueMap(metadataResource);
serialValue = properties.get(Constants.ID,Long.class);
if ((Objects.nonNull(serialValue))) {
Resource rootPathResource = resolver.getResource(Constants.ROOT_PATH);
service.moveAsset(resource, serialValue, resolver, rootPathResource, Constants.ROOT_PATH);
}
resolver.commit();
this.persistData(workItem, workflowSession, Constants.OPERATION_COMPLETED, true);
} catch (LoginException | PersistenceException e) {
log.error("Unable to login or modify/add property as '{}'", ServiceUser.SERVICE_USER, e);
}
}

}

 

I checked inside /var path and workflowitem node shows all status as completed. But the main parent node status is showing as RUNNING.

P_V_Nair_2-1671113573902.png

 

 

Anyone has faced this issue or have any leads?

6 Replies

Avatar

Community Advisor

Hello @P_V_Nair 

Can you please cross-check, if Handler Advance is configured for the Workflow Step?

 

Then it will automatically advance to next step.

 

Please refer to https://experienceleague.adobe.com/docs/experience-manager-64/developing/extending-aem/extending-wor...


Aanchal Sikka

Avatar

Level 4

Hi @P_V_Nair ,

Did you try to complete workflow in your custom workflow process step. 

 

 

// querying work items
WorkItem[] workItems = wfSession.getActiveWorkItems();
WorkItem workItem = wfSession.getWorkItem(id);

// getting routes
List<Route> routes = wfSession.getRoutes(workItem);

// completing or advancing to the next step
wfSession.complete(workItem, routes.get(0));

//optionaly terminate the current workflow programmatically
wfSession.terminateWorkflow(workItem.getWorkflow());

 

 


Note: Please ensure that Handler Advance is checked and your workflow model is synced after edit. 

akashdeepAEM_0-1671140390449.png

 


Reference https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/extending-wor... 
 
Thanks

Avatar

Adobe Champion

@aanchal-sikka @akashdeepAEM @Nikita___Garg I could see that workflows are still in running status and one thing I noticed which is contributing to this is that, after every deployment ,the green check in the workflow is going and it is not synced.

 

Avatar

Employee Advisor

hi @P_V_Nair ,

 

May I know how many workflows are in running state in the existing instance?

 

Whether this is happening with this workflow only or others as well?

 

Thanks,

Nikita Garg