AEM Workflow
Workflow provides us the capability to execute number of tasks depending on conditions or user inputs mostly on content or asset.
Workflow mostly used for content or asset activation.
Workflow is nothing but a series of steps we want to execute depending on inputs.
Workflow Step
There are various types of steps are available.
We will be referring to brand new workflow to learn more about workflow step.
Container Step
Container Step is responsible to load workflow model.
In below example, Container Step is loading Practice Content Workflow Model having series of steps.
This means as part of container steps we are loading multiple series of steps.
AND Step
AND Split allow us to create more than one branches. Each branch is require to configure with step. All branches are required to successfully execute before proceeding to next step.
More branches can be added as part of AND Split configuration as shown below.
OR Step
OR Split allow us to create more than one branches. Each branch is require to configure with step. As part of OR Split only one branch is required to successfully execute before proceeding to next step.
More branches can be added as part of OR Split configuration as shown below.
Participant Step
Participant step provides us the capability to assign ownership of task to specific groups or users.
We can configure User/Group as part of Participant step.
We will be discussing more about participant step below as part of workflow implementation section.
Dialog Participant Step
Dialog Participant Step provide us the capability to collect an input from participant as part of dialog input.
We can configure same component dialog as part of participant dialog to collect data.
Below is just an example to configure component dialog as part of participant step to collect data as input by participant.
Below is the workflow execution screenshot having highlighted fields to collect input from participant.
Dynamic Participant Step
Dynamic Participant step provides us the capability to assign ownership of task to specific groups or users at run time.
Dynamic Participant step is also having the capability what dialog participant step is having to provide a dialog to get an input from participant.
Process Step
Process Step allow us to execute an ECMAScript or OSGI service as shown below.
It can be OOTB or custom process.
Ways To Trigger a Workflow
There are mainly three ways to trigger a workflow:
- Using Launcher: Launchers get call in case of any update in node depending on path and resource type.
- Using Workflow API inside Servlet, Sling model etc.
- Manually using workflow console.
Workflow Console
Open URL and follow blow steps for traversing to Workflow section.
Models: All OOTB and custom workflow model lies under this section.
Instances: It contains workflow which are running or in pending state.
Launchers: All OOTB or custom launchers lies under this section.
Archive: List of all completed and successfully executed workflows.
Failures: List of all failed workflows.
Workflow Use Case and Implementation
We have some pages that were authored by content authors. Content authors will send these pages to content admins for review once authoring is done. Pages will be reviewed by content admins before being published. Pages will get published if approved by content admins. Otherwise, workflow will skip publish step and jump to stop without page publish.
Create content author and content admin user to implement above use case.
- Open http://localhost:4502/useradmin URL to create user.
Click on Edit -> Create -> Create User
2. Enter below inputs and click on Create button to create user.
Login ID and Last Name as practice-content-author
Password: Test@!123
Repeat above step to create practice-content-admin user.
3. Provide below permission to both the users practice-content-author and practice-content-admin
Create a workflow model using OOTB steps
Workflow model is a combination of various steps such as process, participant, dynamic participant, etc.
Follow below steps to create a workflow model for page or asset activation:
- Open URL and click on Models tile for navigating to Models section.
2. Click on Create button to create a brand new model
3. Provide Title for workflow model and click on Done button.
4. Select newly created workflow model as click on Edit button to add workflow steps.
5. Click on Drag components here parsys to drag and drop step.
6. Select Participant Step option.
7. Click on configure button to author Participant step. Traverse to User/Group tab to add participant-content-admin user.
participant-content-admin will be responsible to approve or reject page activation to publish.
8. Drag and drop OR Split. This will have two branches, one for publishing a page and other one is to stop process.
9. Below view will appear after dragging and dropping one participant step and OR split.
10. On Branch 1 drag drop Activate Page/Asset step as shown below.
11. On Branch 2 drag drop Process Step as shown below. This is a blank process placeholder step which will do nothing and jump to next step which is Stop.
12. Configure above process step and update Title as Reject as shown below.
13. Click on Sync will always pick latest configurations from workflow model while execution on page or asset.
Consume/Start workflow
- Login in AEM instance as practice-content-author / Tested@!123 and open any page to Start Workflow as shown below.
2. Select workflow created earlier as shown below and click on Start Workflow.
This will start workflow and send notification to practice-content-admin user.
3. Login in AEM instance as practice-content-admin / Tested@!123 and click on notification as shown below.
4. Select notification and click on complete highlighted option as shown below.
5. Select Activate Page/Asset will publish page and click on Reject will call process step which will be calling Flow End step to complete workflow.
Imran Khan, Adobe Community Advisor, AEM certified developer and Java Geek, is an experienced AEM developer with over 11 years of expertise in designing and implementing robust web applications. He leverages Adobe Experience Manager, Analytics, and Target to create dynamic digital experiences. Imran possesses extensive expertise in J2EE, Sightly, Struts 2.0, Spring, Hibernate, JPA, React, HTML, jQuery, and JavaScript.