Retrieving workflows instances for a specific model
Hi,
I am working in a multi tenant AEM instance. We are trying to retrieve workflow instances running/in any state for a particular model. We tried using getAllworkflows() which will give workflow instances of all the models. We tried few approaches but not working as expected. Can you please suggest any solution for the same?
AEM 6.5 with sp21
cc: @arunpatidar @aanchalsikka
try (ResourceResolver resourceResolver = ResourceResolverUtils.getServiceResourceResolver(resourceResolverFactory, "testworkflowService")) {
logger.info("Fetching workflow instances using JCR query");
Session session = resourceResolver.adaptTo(Session.class);
List<Workflow> runningWorkflows = new ArrayList<>();
WorkflowSession wfSession = resourceResolver.adaptTo(com.adobe.granite.workflow.WorkflowSession.class);
try {
if (wfSession != null) {
Workflow[] wf = wfSession.getAllWorkflows();
}
}
}