Publish Assets on update using workflow launcher

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 :-

  1. You want to trigger email work flow when someone modify pages
  2. Automatic publish dam assets when someone update metadata
  3. 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

Activation Step in Workflow Model

Once completed Save it from top.

Step 2

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

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.)

Let me know if you face any issue in implementation.

4 thoughts on “Automatically publish assets on modification using Workflow Launcher in AEM

  1. Hi Praveen,

    All are working fine. Once concern is the workflow is triggering even when any asset is uploaded. The event Type I selected is “Node Modified” only.

    I need to trigger only when I update the metadata. How to achieve this. I can add a condition(like custommetadata!=) but is there any other way.

    Thanks,
    Selva

     
  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

     

Leave a Reply

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