Expand my Community achievements bar.

SOLVED

Workflow Dynamic Participant Step

Avatar

Level 4

Hi,

 

I have created custom Dynamic Participant Step and getting user from arguments section from Participant chooser column and assigning flow to that person.

 

This follow is working fine for single user but when I am passing AEM group. Workflow is not assigning  to all person who all are in that group.

 

Do I need to use any osgi api which will extract all user within that AEM group ?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @chetan001 

  Yes. You can get member emails from group.

Sharing sample code snippet  for your reference 

final UserManager userManager = resourceResolver.adaptTo(UserManager.class);  
final Resource groupRes = resourceResolver
                        .getResource(userManager.getAuthorizable(/////PASS_GROUP ).getPath());
                final Group group = groupRes == null ? null : groupRes.adaptTo(Group.class);
           final Iterator<Authorizable> memberslist = group.getMembers();
        while (memberslist.hasNext()) {
            final Authorizable user = memberslist.next();
            if (user != null && !user.isGroup() && user.getProperty("./profile/email") != null) {
// EMAIL ADDRESS FOR MEMBERS
             user.getProperty("./profile/email");
            }

  

View solution in original post

6 Replies

Avatar

Employee Advisor

Hi @chetan001 ,

 

Please check the below article here its shown how to pick the group and user 

 

https://aem.redquark.org/2019/09/workflows-in-aem-03-dynamic-participant.html

 

You can create a custom  Dynamic Participant workflow step by implementing ParticipantStepChooser. When creating a Dynamic Participant Step, you can use application logic to determine whom to assign the workflow item. In your logic, you can get group information too. All of this can be coded.

 

Hope this helps!!

Thanks

Avatar

Community Advisor

Hi @chetan001 

  It should get assigned to all members of selected group.

Can you share your Participant Chooser step code snippet?

 

Thanks

Dipti Chauhan

Avatar

Level 4

Hi @Dipti_Chauhan 

thanks for your reply

 

Yes tested, it is assigning to all members. But As per second requirement custom email should be sent to all that users which is in this AEM group. UserManager Api should work here. Right ? to get user from groups

Avatar

Correct answer by
Community Advisor

Hi @chetan001 

  Yes. You can get member emails from group.

Sharing sample code snippet  for your reference 

final UserManager userManager = resourceResolver.adaptTo(UserManager.class);  
final Resource groupRes = resourceResolver
                        .getResource(userManager.getAuthorizable(/////PASS_GROUP ).getPath());
                final Group group = groupRes == null ? null : groupRes.adaptTo(Group.class);
           final Iterator<Authorizable> memberslist = group.getMembers();
        while (memberslist.hasNext()) {
            final Authorizable user = memberslist.next();
            if (user != null && !user.isGroup() && user.getProperty("./profile/email") != null) {
// EMAIL ADDRESS FOR MEMBERS
             user.getProperty("./profile/email");
            }

  

Avatar

Level 4

@Dipti_Chauhan Is it possible to return multiple users in getParticipant() rather returning a group? Since the return type of getParticipant() is String, is there a way we can return multiple users?