내 커뮤니티 업적 표시줄을 확대합니다.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
해결됨

Need Help with AEM Approval Workflow Initiator

Avatar

Level 1

Hello there,

 

I'm currently  working on an AEM Approval Workflow, and I've hit a bit of a roadblock. I'm struggling to properly set up the initiator, and I could use some assistance.

 

Here's a breakdown of my workflow:

PRHebert_0-1710353653269.png

 

The Manager Approval task is a custom implementation of ParticipantChooser, where I retrieve the workflow initiator using:

 

 

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

 

 

Afterward, I identify all the groups this user belongs to and match the author group to the approval groups. This part works smoothly when I manually start the workflow.

However, my goal is to streamline the process for authors by triggering the workflow automatically when the authors publish content using a launcher.

 

Here lies the issue: when the launcher triggers the workflow, the user is set to "workflow-service" which prevents me from finding the correct approvers.

 

I tried using the metadata

 

 

String initiator2 = workItem.getWorkflowData().getMetaDataMap().get("userId", String.class);

 

 

Or the workflowSession history but no luck so far.

 

 

* Get workflow history */
final List<HistoryItem> histories = workflowSession.getHistory(workItem.getWorkflow());

/* Get last item in workflow history */
final HistoryItem lastItem = histories.get(histories.size() - 1);

/* Get the user that participated in the last item */
final String lastUser = lastItem.getUserId();

 

 

Any other way I can achieve this programmatically or should I find another approach?
 
Thanks.
1 채택된 해결책 개

Avatar

정확한 답변 작성자:
Level 3

@PRHebert - would the author who published the page be considered as initiator?

If yes, you can obtain property lastReplicatedBy from payload node.

 

원본 게시물의 솔루션 보기

4 답변 개

Avatar

Community Advisor


https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-retrieve-the-email-...
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);

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/aem-workflow-set-user-inpu...

 

Avatar

정확한 답변 작성자:
Level 3

@PRHebert - would the author who published the page be considered as initiator?

If yes, you can obtain property lastReplicatedBy from payload node.

 

Avatar

Level 1

Thanks @VatsalGupta I was able to get unblock by using this.

lastReplicatedBy = payloadNode.getProperty("cq:lastReplicatedBy").getString();

Avatar

Administrator

@PRHebert Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni