Getting the list of failure workflow through api in java



I have one more question if you can help me out it would be great ..There is one scenerio where we have to create a scheduler batch job  to  get the list of "running workflos which are older than month" and "Failure workflow at the time when my job is running ".....the question is how to get the list of failure workflows .....

I know the workflow api is availble like getWorkflow(state--running/aborted) like that but how to get failure one ...if I see in var as well there is no sign of failed status anywhere how i will get failed workflow list ?...even if we go to Failure tab of workflow it shows workflow state running only to differentiate and get the list of failure workflows only ?

Accepted Solutions (1)

Accepted Solutions (1)




Hi @AdobeID24,

Workflow displayed in Failure console can be in any state -  Running / Completed. It will be the individual work items which is with error/exception. 

You can find those failure items at  workItems node under run time instance path in /var. (workflows completed without any errors doesn't has any workItems under it)

Example : /var/workflow/instances/server0/2020-05-26/dam-unarchiver_37/workItems

Sample screenshot from my local



metaData node has details about the failures (as we see in the console)




Looks like there is no straight forward API to get the workItems(entry for failed items) available immediately under the run time instance path.

From the list of all "RUNNING" workflows, you can get the run time instance path via getId() method.

With that path, you can either use Resource or Node API to get workItems. 

Sample snippet for reference:

String[] states = {"RUNNING", "COMPLETED"};
WorkflowSession wfSession = workflowService.getWorkflowSession(session);
Workflow[] wf = wfSession.getWorkflows(states);
for (int i = 0; i < wf.length; i++) {
	String wfId = wf[i].getId(); // This will give - /var/workflow/instances/server0/2020-05-26/dam-unarchiver_37
	Resource wfInstanceResc = req.getResourceResolver().resolve(wfId); 
	/* From here, can continue with Resource API or adapt to Node and continue further */

Answers (0)