I tried to get current user using session and authorizable. But none of them giving the current user who invokes the particular step.
Is there any other way to get the current user details ?
In your execute method try the following
You can use getInitiator() method of Workflow API to get the user ID of the user who started the workflow.
Refer https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/javadoc/co... API to get to know more about this particular method.
Returns the initiator of the Workflow instance.
The user who initiated the Workflow.
Hope it helps!
I understand that you need the userId of the most recent participant in your workflow. This can be fetched as follows:
Step1: workflowSession.getHistory. This should return the history of workflow:
List<HistoryItem> histories = workflowSession.getHistory(workItem.getWorkflow());
Step2: The most recent action of the participant user should be the first item in the histories list at index 0, and this can be accessed as:
HistoryItem recentHistory = histories.get(0);
Step3: The recent user id can be fetched using the getUserId method of HistoryItem:
String recentUser = recentHistory.getUserId();
Please let me know if this works.