Expand my Community achievements bar.

SOLVED

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

Avatar

Level 4

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 ? 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 4

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

View solution in original post

3 Replies

Avatar

Correct answer by
Level 4

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

Avatar

Level 4

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!!

Avatar

Employee Advisor

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... 

 

Hope this helps.

 

Regards,

Nitesh