After completing this tutorial you will be able to answer what are :
- Basics of AEM Workflow Model.
- How to create a Workflow Model in AEM.
- How to add a step to Workflow Model in AEM.
- How to edit a Workflow Step in AEM.
- How to Start Workflow in AEM or Test Workflow in AEM.
Basics of AEM Workflow Model
Creating a workflow allows user to define and execute a series of steps. In AEM we call workflow as Workflow models . Below are the basic terms used in aem workflow model.
Model : It is made up of WorkflowNodes and WorkflowTransitions. Workflow models are versioned. Running Workflow Instances keep the initial workflow model version that is set when the workflow is started.
Step : There are different types of workflow steps:
Participant (User/Group): These types of steps generate a work item and assigns it to a user or group. A user must complete the work item to advance the workflow.
Process (Script, Java method call): This type of step is executed automatically by the system. An ECMA script or Java class implements the step.
Container (Sub Workflow): This step starts another workflow model.
OR Split/Join: Uses logic to decide which step to execute next in the workflow.
AND Split/Join: Executes multiple steps simultaneously.
All the steps share the following common properties: Auto advance and Timeout alerts (scriptable).
Transition : Defines the link between two consecutive steps.
WorkItem : A workflow instance can have one or many WorkItems at the same time (depending on the workflow model).
Payload : References the resource that has to be advanced through a workflow.
The payload implementation references a resource in the repository (by either a path or an UUID) or a resource by a URL or by a serialised java object. Referencing a resource in the repository is very flexible and in conjunction with sling very Productive: for example the referenced node could be rendered as a form.
Lifecycle : It is created when a new workflow is started and ends when the end node is processed.
Creating a workflow allows user to define and execute a series of steps. In AEM we call workflow as Workflow models . Below are the basic terms used in aem workflow model.
Model : It is made up of WorkflowNodes and WorkflowTransitions. Workflow models are versioned. Running Workflow Instances keep the initial workflow model version that is set when the workflow is started.
Step : There are different types of workflow steps:
Participant (User/Group): These types of steps generate a work item and assigns it to a user or group. A user must complete the work item to advance the workflow.
Process (Script, Java method call): This type of step is executed automatically by the system. An ECMA script or Java class implements the step.
Container (Sub Workflow): This step starts another workflow model.
OR Split/Join: Uses logic to decide which step to execute next in the workflow.
AND Split/Join: Executes multiple steps simultaneously.
All the steps share the following common properties: Auto advance and Timeout alerts (scriptable).
Transition : Defines the link between two consecutive steps.
WorkItem : A workflow instance can have one or many WorkItems at the same time (depending on the workflow model).
Payload : References the resource that has to be advanced through a workflow.
The payload implementation references a resource in the repository (by either a path or an UUID) or a resource by a URL or by a serialised java object. Referencing a resource in the repository is very flexible and in conjunction with sling very Productive: for example the referenced node could be rendered as a form.
Lifecycle : It is created when a new workflow is started and ends when the end node is processed.
The following actions are possible on a workflow instance:
Inbox : Each logged in user has its own workflow inbox in which the assigned WorkItems are accessible.
Launcher : Allows you to define a workflow to be launched if a specific node has been updated.
When we create a new workflow model it consist of three default steps Flow Start ,Flow End and a dummy participant step named as step 1.
Flow Start and Flow End represent start and end of workflow.
Step1 Participant Step is assigned to admin user to configure a work step. We can edit or delete this step and add new steps as required.
- Terminate
- Suspend
- Resume
- Restart
Inbox : Each logged in user has its own workflow inbox in which the assigned WorkItems are accessible.
Launcher : Allows you to define a workflow to be launched if a specific node has been updated.
When we create a new workflow model it consist of three default steps Flow Start ,Flow End and a dummy participant step named as step 1.
Flow Start and Flow End represent start and end of workflow.
Step1 Participant Step is assigned to admin user to configure a work step. We can edit or delete this step and add new steps as required.
Create a Workflow Model in AEM
Open the Workflow console (http://localhost:4502/libs/cq/workflow/content/console.html)
Select Models tab –> Click New.
Open the Workflow console (http://localhost:4502/libs/cq/workflow/content/console.html)
Select Models tab –> Click New.
The New Workflow dialog will open –> Type the Title and Name for your workflow and click OK.
Your new workflow model appears in model tab.
Note: It's a good practice to keep Name field in lowercase. As it acts as an id and does not accept space between words. Title acts as display name.
Add Steps to Workflow Model
Steps are used to represent an activity to be performed in Workflow. AEM comes with several pre-installed steps. When we open the workflow in edit mode, you can see all available processes that can be added to any step in workflow model.
Go to Model tab of workflow console. Either select workflow model right click on it and click edit or double click on selected workflow model.
Note: It's a good practice to keep Name field in lowercase. As it acts as an id and does not accept space between words. Title acts as display name.
Add Steps to Workflow Model
Steps are used to represent an activity to be performed in Workflow. AEM comes with several pre-installed steps. When we open the workflow in edit mode, you can see all available processes that can be added to any step in workflow model.
Go to Model tab of workflow console. Either select workflow model right click on it and click edit or double click on selected workflow model.
Drag a workflow model step from the sidekick and drop on indicated area as shown in below figure. A green checkmark icon on the workflow component indicates its a valid drop zone.
Note: Workflow steps always execute in the order in which they appear in workflow model.
Edit a Workflow Step
For editing a workflow step we can either use the default step1 or we can create a new one. In this example we are going to use the new participant step that we have created above .
For editing a workflow model step in AEM. Follow below steps:-
Right click and delete the default Step 1.
Right-click the participant step and click Edit.
Note: Workflow steps always execute in the order in which they appear in workflow model.
Edit a Workflow Step
For editing a workflow step we can either use the default step1 or we can create a new one. In this example we are going to use the new participant step that we have created above .
For editing a workflow model step in AEM. Follow below steps:-
Right click and delete the default Step 1.
Right-click the participant step and click Edit.
Enter the values for Title and Description and Enter timeout setting as immediate and handler as Auto Advancer to move to next step. For example Validate Content.
Set the User/Group to admin, it will show you a drop down list of valid users and groups and click OK.
Drag an Or Split onto the workflow available above participant step in sidekick and position it between Validate Content workflow step and Flow End step.
Right-click the Or Split step and click Edit.
We can choose only one default route. For Branch 1, select Default Route. For Branch 2, ensure Default Route is not selected and click OK.
You can provide a custom script in Script Text Area or create a ecma script under apps/<project>/workflow/scripts/ and enter the path in Script Path Text box.
Drag a Participant Step component to the left-hand branch, open the properties, specify the following property values, and click OK:
Title: Cancel Publish.
User/Group: admin.
Timeout: Immediate.
Timeout Handler: Auto Advancer.
Drag a Process Step to the right-hand branch, open the properties, specify the following values, and click OK:
Title: Publish Page
Process: Select Activate Page. This process publishes the selected page to the publisher instances. Check Handler Advance to auto move to Next Step.
Drag a Participant Step component to the left-hand branch, open the properties, specify the following property values, and click OK:
Title: Cancel Publish.
User/Group: admin.
Timeout: Immediate.
Timeout Handler: Auto Advancer.
Drag a Process Step to the right-hand branch, open the properties, specify the following values, and click OK:
Title: Publish Page
Process: Select Activate Page. This process publishes the selected page to the publisher instances. Check Handler Advance to auto move to Next Step.
Click Save on Top Left.
Note: Always click on Save otherwise your changes won’t get reflected.
Start Workflow in AEM or Test Workflow in AEM
Open the Workflow console (http://localhost:4502/libs/cq/workflow/content/console.html)
Select Models tab –> Right click on Training workflow -> Click Start.
Start Workflow window will open.
Select Payload from content –> Click OK.
Enter Workflow Title. Ex. Training Workflow.
Click OK on Workflow Window.
Go to Instances tab. Your training workflow instance will be listed here. You can Terminate, Suspend or check status of workflow instance from here.
No comments:
Post a Comment
If you have any doubts or questions, please let us know.