How to retrieve the email address of a user who is initiating the workflow ? | Community
Skip to main content
Ankan_Ghosh
Level 3
January 11, 2023
Solved

How to retrieve the email address of a user who is initiating the workflow ?

  • January 11, 2023
  • 2 replies
  • 1299 views

I have a process step in a workflow which is used to send mail to the initiator of the workflow on getting certain approval or rejection . How do I find the Email ID associated with that particular user in the process step ? How do I retrieve the user from the Workflow Item ? 

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 Harishv31

Hi,

From workflow item ,you can retrieve user id by this code below

item.getWorkflow().getInitiator();

 

Code to get mail id .

 

resourceResolver = getResourceResolver(workflowSession.getSession());

            UserManager manager = resourceResolver.adaptTo(UserManager.class);

            Authorizable authorizable = manager.getAuthorizable(workItem.getWorkflow().getInitiator());

            Value[] email = authorizable.getProperty("./profile/email");

            System.out.println(email);

 

Thanks

2 replies

Harishv31Accepted solution
Level 3
January 11, 2023

Hi,

From workflow item ,you can retrieve user id by this code below

item.getWorkflow().getInitiator();

 

Code to get mail id .

 

resourceResolver = getResourceResolver(workflowSession.getSession());

            UserManager manager = resourceResolver.adaptTo(UserManager.class);

            Authorizable authorizable = manager.getAuthorizable(workItem.getWorkflow().getInitiator());

            Value[] email = authorizable.getProperty("./profile/email");

            System.out.println(email);

 

Thanks

Ankan_Ghosh
Level 3
January 12, 2023

I could  not get the Resource Resolver using the steps that you suggested , so I instead adapted the workflow session into ResourceResolver and the program worked. 

Thanks for the help!!

nitesh_kumar-1
Adobe Employee
Adobe Employee
January 11, 2023

Hi @ankan_ghosh ,

 

You can retrieve the User from the workItem in process step.

 

workItem.getWorkflow().getInitiator()

 

and make use of UserManager API to fetch further details.

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/org/apache/jackrabbit/api/security/user/UserManager.html 

 

Hope this helps.

 

Regards,

Nitesh