AEM Dynamic Participant Step

AEM Dynamic participant step is used for assigning ownership of task to some other user. Completion of task will require a comment from assigned user.

Implement ParticipantStepChooser interface and override getParticipant() method to create custom Dynamic participant step. Refer this URL to read more about workflow, model and its steps.

Follow below syntax to implement workflow process step.

@Component(service = ParticipantStepChooser.class,
    property = { "chooser.label=" + "Dynamic Participant Workflow"
})
public class DynamicParticipantStep implements ParticipantStepChooser {

   @Override
   public String getParticipant(WorkItem workItem, WorkflowSession workflowSession,
        MetaDataMap metaDataMap)  throws WorkflowException {

        return  "Group/User";
   }
}

WorkItem: This contains workflow data as shown below

WorkflowSession: It provides the complete capability to manage workflow models and instances. Workflow session allows us to provide complete on workflow model, items, active items, workflows(running, abort, completed).

MetaDataMap: It provide access to data map and arguments passed as an input.

Dynamic Participant Step Implementation

Follow below step to create and consume dynamic participant step:

1. Create a Java class. Implement ParticipantStepChooser interface and override getParticipant() method as show below:

import org.osgi.service.component.annotations.Component;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.adobe.granite.workflow.WorkflowException;
import com.adobe.granite.workflow.WorkflowSession;
import com.adobe.granite.workflow.exec.ParticipantStepChooser;
import com.adobe.granite.workflow.exec.WorkItem;
import com.adobe.granite.workflow.exec.Workflow;
import com.adobe.granite.workflow.metadata.MetaDataMap;

@Component(service = ParticipantStepChooser.class,
    property = { "chooser.label=" + "Dynamic Participant Workflow"
})
public class DynamicParticipantStep implements ParticipantStepChooser {

   private final Logger log = LoggerFactory.getLogger(this.getClass());

   @Override
   public String getParticipant(WorkItem workItem, WorkflowSession workflowSession,
        MetaDataMap metaDataMap)  throws WorkflowException {

        log.info("Entering DynamicParticipantStep >>>>>> ");
        Workflow workflow = workItem.getWorkflow();

        return  "practice-content-author";
   }
}

2. Create practice-content-author to implement complete use case as we are returning or assigning ownership of task to practice-content-author.

Open http://localhost:4502/useradmin URL to create user.

Click on Edit -> Create -> Create User

3. Enter below inputs and click on Create button to create user.

Login ID and Last Name as practice-content-author

Password: Test@!123

4. Provide below permission to both the users practice-content-author

5. Create workflow model and dynamic participant step to consume above created java class for dynamic participant custom step. Open URL and click on Models tile for navigating to Models section.

6. Click on Create button to create a brand new model

7. Provide Title for workflow model and click on Done button.

8. Select newly created workflow model as click on Edit button to add workflow steps.

9. Click on Drag components here parsys to drag and drop step.

10. Drag and drop Dynamic Participant Step as shown below.

11. Configure Dynamic Participant step and provide participant choose backend OSGI class created as part of Step1.

12. Click on Sync will pick latest configurations from workflow model while execution.

13. Open any page to Start Workflow as shown below.

14. Select workflow created earlier as shown below and click on Start Workflow to start workflow execution.

15. Check error.log file as getParticipant() method from DynamicParticipantStep.java class get call as soon as click on Start Workflow button.

16. Login with practice-content-author user in AEM and check for below notification:

17. Clicking on Dynamic Participant notification will take us to workitem page. Click on complete as shown below.

18. Provide comment and click on OK will complete this workflow step.

19. Below is the screenshot from workflow archive section of completed workflow.  

Imran Khan

Specialist Master (Architect) with a passion for cutting-edge technologies like AEM (Adobe Experience Manager) and a proven track record of delivering high-quality software solutions.

  • Languages: Java, Python
  • Frameworks: J2EE, Spring, Struts 2.0, Hibernate
  • Web Technologies: React, HTML, CSS
  • Analytics: Adobe Analytics
  • Tools & Technologies: IntelliJ, JIRA

🌐 LinkedIn

📝 Blogs

📧 Imran Khan