Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Getting the list of failure workflow through api in java

Avatar

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile

Avatar
Contributor 2
Level 4
AdobeID24
Level 4

Likes

54 likes

Total Posts

153 posts

Correct Reply

1 solution
Top badges earned
Contributor 2
Validate 10
Validate 1
Ignite 5
Ignite 3
View profile
AdobeID24
Level 4

15-09-2020

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 ...so how i will get failed workflow list ?...even if we go to Failure tab of workflow it shows workflow state running only ...how to differentiate and get the list of failure workflows only ?

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

564 likes

Total Posts

707 posts

Correct Reply

234 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile

Avatar
Boost 500
MVP
Vijayalakshmi_S
MVP

Likes

564 likes

Total Posts

707 posts

Correct Reply

234 solutions
Top badges earned
Boost 500
Give Back 50
Give Back 5
Ignite 10
Ignite 5
View profile
Vijayalakshmi_S
MVP

15-09-2020

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

Vijayalakshmi_S_0-1600192823293.png

 

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

Vijayalakshmi_S_1-1600192987370.png

 

 

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 */
}
AdobeID24

@Vijayalakshmi_S is there any api to read the jcr:property of child nodes of workitems as you shown in your screenshot..Thnaks it would be really helpful ...I tried using getworkitems.getnodes and some other here and there but it didnt work out for me . Can you help me on that to read ?

 

First i get the list of all runnning workflow then from all running worflow I want to check or access the workitesm child nodes jcr:property .

 

Vijayalakshmi_S

Hi @AdobeID24,

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)