Expand my Community achievements bar.

SOLVED

Issue in fetching the title of the current workflow step

Avatar

Level 1

Hi,

 

I want to fetch the title and description of a dynamic participant step that I'm currently in. I tried using

workItem.getNode().getTitle() but it returns the title of the previous step and not the current one (dynamic participant step). Is there any way to fetch the details of the current step in workflows?

 

@arunpatidar@Vijayalakshmi_S 

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi @red_devil,

I am able to reproduce the behavior you have mentioned. 

As part of debugging, could find that the workItem Id being in ParticipantChooser Implementation returns as VolatileWorkItem.

(You can log this line of code workItem.getId() -> VolatileWorkItem_node0_var_workflow_instances_server0_2021-03-08_sampleworkflow_10)

On a very high level, with this information could suspect that the details with respect to the workItem node like title, description is not accessible/not in the vicinity of ParticipantChooser implementation. 

Alternatively, you can consider use of  "Arguments" field  of Dynamic participant step to pass inputs along the lines of title/description.(which shall then be retrieved from MetaDataMap, third argument of getParticipant method)

While the same line of code - workItem.getNode().getTitle() being executed from process step will return its respective details (title as authored in process step)

Note : As the granite workflow implementation is hidden, couldn't arrive at the exact reason for this behavior.

View solution in original post

5 Replies

Avatar

Community Advisor

Hi,

Try using WorkflowSession to get the current work item.



Arun Patidar

Avatar

Level 1
I tried using workflowSession.getActiveWorkItems() but this one also returns the previous step details. I tried to access the "/var/workflow/instances/<server>/<date>/<workflow_id>/workItems" but it also had the previous step details at the time I'm trying to fetch the dynamic participant step details

Avatar

Community Advisor
ok, I will try and let you know


Arun Patidar

Avatar

Community Advisor

Hi, I just tried this and I am able to get the workflow title and description in the step.

 

List<WorkflowTransition> list = workItem.getNode().getTransitions();
for (WorkflowTransition item : list) {
     log.info("Workflow Step Title {}",item.getTo().getTitle());
}

 

logs

08.03.2021 21:17:50.828 *INFO* [0:0:0:0:0:0:0:1 [1615234670817] POST /bin/workflow/inbox HTTP/1.1] com.aemlab.aem65.core.services.DynamicReviewer Workflow Step Title Dynamic Participant Title 



Arun Patidar

Avatar

Correct answer by
Level 10

Hi @red_devil,

I am able to reproduce the behavior you have mentioned. 

As part of debugging, could find that the workItem Id being in ParticipantChooser Implementation returns as VolatileWorkItem.

(You can log this line of code workItem.getId() -> VolatileWorkItem_node0_var_workflow_instances_server0_2021-03-08_sampleworkflow_10)

On a very high level, with this information could suspect that the details with respect to the workItem node like title, description is not accessible/not in the vicinity of ParticipantChooser implementation. 

Alternatively, you can consider use of  "Arguments" field  of Dynamic participant step to pass inputs along the lines of title/description.(which shall then be retrieved from MetaDataMap, third argument of getParticipant method)

While the same line of code - workItem.getNode().getTitle() being executed from process step will return its respective details (title as authored in process step)

Note : As the granite workflow implementation is hidden, couldn't arrive at the exact reason for this behavior.