Is it possible to get the current user in the workflow? | Community
Skip to main content
Employee
April 5, 2022
Solved

Is it possible to get the current user in the workflow?

  • April 5, 2022
  • 3 replies
  • 1532 views

I have created a workflow model. Where initiator/author triggers the workflow and assign the payload for approve to the approver. Approver will be triggering the process step. How can I get the approver details in process step? or how can I get the current user details in my workflow?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by raushan123

To get intiator/author :

String intiator = workItem.getWorkflow().getInitiator();

to get approvar details

you have to get it from user manager api.

UserManager userManager = resolver.adaptTo(UserManager.class);
Set<String> toEmails = new TreeSet<>();
Authorizable user = userManager.getAuthorizable(authId);
validateAuthroable(userManager, toEmails, user);

3 replies

raushan123Accepted solution
New Participant
April 6, 2022

To get intiator/author :

String intiator = workItem.getWorkflow().getInitiator();

to get approvar details

you have to get it from user manager api.

UserManager userManager = resolver.adaptTo(UserManager.class);
Set<String> toEmails = new TreeSet<>();
Authorizable user = userManager.getAuthorizable(authId);
validateAuthroable(userManager, toEmails, user);

arunpatidar
New Participant
April 5, 2022

Hi,

You can get the approver details from the workflow instance. All the information related to the workflow is stored at the /var/workflow/instances.

 

You can use workflow APIs to fetch the details of users who acted on this workflow instance.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/adobe/granite/workflow/exec/package-summary.html

Arun Patidar