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 ?
Solved! Go to Solution.
Views
Replies
Total Likes
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 */
}
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 */
}
@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 .
Views
Replies
Total Likes
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 */
}
Views
Replies
Total Likes