Workflow Dynamic Participant Step

 

Workflows in Adobe Experience Manager (AEM) has multiple participant steps like

  • Participant Step
  • Dynamic Participant Step
  • Dialog Participant Step
  • Form Participant Step

in which a user or a group will be assigned as a owner of that particular step. Each of these participant steps are used based on the usecase. Let us see in this blog on how to use and write a dynamic participant step.

Workflow Dynamic Participant Step is used when the user or a group to perform an activity in that step is selected automatically at run time based on some business logic unlike the user or a group are pre-selected. When we select the dynamic participant step in the workflow, we need to select the respective participant chooser from the drop down. There are many script/service available out of the box to select from or we can write our own participant chooser service as well which will be discussed further in this post.

Follow the below steps

1. Create a service class in the bundle (Sample shown below) and for a service to be identified as a participant step

  • implement ‘ParticipantStepChoose’ interface
  • override ‘getParticipant()’ method
  • Property name ‘ParticipantStepChooser.SERVICE_PROPERTY_LABEL’ to give the label that comes in the dropdown

@Component(immediate=true)
@Service
@Properties({
@Property(name = Constants.SERVICE_DESCRIPTION, value = “Sample Implementation of dynamic participant chooser.”),
@Property(name = ParticipantStepChooser.SERVICE_PROPERTY_LABEL, value = “Sample Workflow Participant Chooser”)
})

public class SampleParticipantStepChooserImpl implements ParticipantStepChooser {

private static final Logger logger = LoggerFactory.getLogger(SampleParticipantStepChooserImpl.class);

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

String participant = “admin”;
Workflow wf = workItem.getWorkflow();
List<HistoryItem> wfHistory = wfSession.getHistory(wf);
if(!wfHistory.isEmpty()){
participant = “administrators”;
}else{
participant = “admin”;
}
logger.info(“####### Participant : ” + participant + ” ##############”);
return participant;
}

}
2. Build and deploy the bundle and make sure the bundle is in ‘active’ state

3. Create a workflow model, add a dynamic participant step in your workflow

Add Dynamic Participant Step
Add Dynamic Participant Step

4. Click on the step and add the step properties

Add Step Properties
Add Step Properties

5. Click on ‘Participant Chooser’ tab and see if the service you had created is visible and select the same. Click ok

Select the participant step choose script/servcie
Select the participant step choose script/servcie

6. Complete the workflow and ‘save’

Save the workflow
Save the workflow

Now, the participant for this step would be derived out of logic from your service and you can control the same dynamically.

Important Notes:

1. Make sure you are importing the right packages based on the versions of AEM you are using

  • for AEM 5.6.1 and below use com.day.cq.workflow.* packages
  • for AEM 6.0 and above use com.adobe.granite.workflow.* packages

else you might not see the participant chooser service in the dropdown.

2. Deploy your service before you create your workflow.

3. On any change in your service and redeploy of the service, refresh your workflow model and reassign the service to the dynamic participant step to pick up the changes.

4. Any workflow instances that are running with the previous version, would not have the latest changes of the service or the workflow.

You can also refer the AEM Community article which gives the complete steps along with setting up the maven project here 

 

7 thoughts on “Workflow Dynamic Participant Step

  1. Hi Guys,

    I am new to Adobe as a Business Analyst. I will like to post questions from Time to time on wrting User Stories from a Content authors stand point.

     
  2. when publish the page using the sample publish work flow in aem, it only publishing the content not the images I upload from image component. How do I publish the images along with the content in a page. Could you please help me how to implement it.

    thanks
    raj

     
  3. Hi Lokesh,

    I have used “Participant Step” in workflow and I could see user like-admin, Alison Parker, group – administrators,Hiking Admins in User/Group drop down list.

    Now, I have created my own user and group and I have given full permission. But, I am not getting my own user/group in the drop down list.

    Please let me know process so, that I could see my own user/group as well.

    Thanks & Regards,
    Debal

     
  4. Workflow that allows multiple users to be assigned as Approver.The selected user’s approvers are stores on a property as string[] in the user’s node. But I’m stuck now as how would I return String[] from my ParticipantStepChooser.getParticipant() method and send AEM Inbox message.

     

Leave a Reply

Your email address will not be published. Required fields are marked *