April 7, 2020
Estimated Post Reading Time ~

Automatically publish assets on modification using Workflow Launcher in AEM



The Workflow Launcher provides one component to monitor all changes in the content repository and launch workflows dependent on the location and resource type of the changed node. Before diving deep into this, lets get a small overview of workflows in AEM.

Workflow in AEM in one of the most useful and powerful feature. It helps one to automate Experience Manager activities. Workflow is a combination of steps which always executes in specific order. You can manage order when you are creating your workflow and same order will be followed every time unless you modify it. Each step performs a distinct activity such as activating a page or sending an email message. Workflows can interact with assets in the repository, user accounts, and Experience Manager services.

A simple example would be Leave Management System, which most of us have used a lot of times. Now when you apply for leave it goes through series of steps, in general those are following:-
  1. Goes to your Reporting Manager for approval
  2. Once RM approved goes to Senior Manager
  3. Once SM approved, it goes to Group Manager
Actual steps in your organisation might be slightly different but I am sure they will be pretty much related to this.

Now, lets get back to Workflow Launcher. In simple terms,

DEPEND ON ANY OF THE THREE EVENT
  • Created
  • Modified
  • Removed
UNDER A NODE YOU CAN TRIGGER ANY WORKFLOW.

A good use cases of these types of scenario can be :-
You want to trigger email work flow when someone modify pages
Automatic publish dam assets when someone update metadata
Send notification to team when a pages gets deleted….

….and many more.

I will demonstrate here the 2nd use case as it was recently asked by a user in Adobe AEM Community. Following we need to do in order to execute above use case:-

Step 1: Create a simple Activation workflow

Step 2: Add a workflow launcher

Lets gets started..

Step 1

1. Go to workflow model and create new workflow model

2. Delete already existing step if there is any and add a workflow step “Activation Page/Asset”

3. You workflow model should look like below



Once completed Save it from top.

Step 2

Go to workflow launcher and create a new workflow with details as shown below

Once created, Click Ok to save.

That’s it, now when ever you update the metadata of a Asset it will automatically replicate it.

Now lets go through the field we have filled in workflow launcher:

1. Event Type: It says at which event workflow should be triggered. It can on creating of node, modification of any property in node or removal of node.

2. Nodetype: The type of node that the workflow launcher applies to. In our case the properties are getting stored in node of type nt:unstructured

3. Path: The path that the workflow launcher should monitor

4. Workflow: The workflow to launch when the Event Type occurs on the Nodetype and/or Path under the defined Condition. In our case Activation Workflow will launch if any modified event occurred at path /content/dam/geometrixx/banners

5. Activate: Controls whether the workflow launcher is activated. When you set it to Enable then only it will launch workflow.

6. Run Mode(s): The type of server that the workflow launcher applies to. Select Author, Publish, or Author&Publish.

Before we end this, there is small exception in case of path where you cannot execute workflow launcher. Even if you set one, it won’t execute
  • /var/audit
  • /var/classes
  • /var/eventing
  • /var/linkchecker
  • /var/mobile
  • /tmp
  • /etc/workflow/instances
  • Any workflow-inbox node located anywhere in the /home/users branch
  • /var/statistics (Exception: Changes to nodes below /var/statistics/tracking do cause workflows to launch.)


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.