Unable to use WorkflowSession in Scheduler/Schedule Workflow Email Reminder
I am writing a scheduler to send an email reminder to approvers in a workflow that has done nothing in 7 days. However, I have no way to grab workflow data because the WorkflowSession that I create returns nothing when using its methods. I know for a fact that there are workflows running on my local instance, so its not that there isn't any active.
Example Code:
private static final String SUBSERVICE_NAME = "workflowServiceUser";
private static final Map<String, Object> authInfo = ImmutableMap.of(ResourceResolverFactory.SUBSERVICE, SUBSERVICE_NAME);
@Reference
private ResourceResolverFactory resolverFactory;
@Reference
WorkflowService workflowService;
ResourceResolver resolver = resolverFactory.getServiceResourceResolver(authInfo);
Session session = resolver.adaptTo(Session.class);
WorkflowSession wfSession = workflowService.getWorkflowSession(session);
//EXAMPLES
//wfSession.getActiveWorkItems(); -Returns 0 results
//wfSession.getAllWorkflows(); -Returns 0 results
//wfSession.getModels(); -for some reason this WORKS
After I determine which workitems are a week old, I need to essentially run our email workflow step again, and the only way to do that is to use the WorkflowSession.
Is there something that I need to be doing differently?