How to retrieve the email address of a user who is initiating the workflow ? | Adobe Higher Education
Skip to main content
Ankan_Ghosh
Level 3
January 11, 2023
해결됨

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

  • January 11, 2023
  • 2 답변들
  • 1299 조회

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 ? 

이 주제는 답변이 닫혔습니다.
최고의 답변: 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 답변

Harishv31답변
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
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