Expand my Community achievements bar.

Adobe Summit 2025: AEM Session Recordings Are Live! Missed a session or want to revisit your favorites? Watch the latest recordings now.
SOLVED

Trigger a workflow on Publish asset only

Avatar

Level 3

Hi, i want to trigger a workflow, which creates a new version of an asset when the user publishes the asset. to achieve this i created a model which has the following steps 1) flow start, 2) Activate Page/Asset, 3) create version 4) Flow end. and then i created a launcher to launch. it is working fine, but when the user modifies any metadata (we have custom or dam or dc) the launcher is triggered. we already have DAM Meta Data write back workflow that is triggered when the metadata is modified and this also creates a new version. so now when the user is modifying any metadata, both the workflows are triggered and 2 versions are created.

 

any ideas as to how to restrict my workflow launcher to publish only??

1 Accepted Solution

Avatar

Correct answer by
Level 3

I found out the solution. adding this "jcr:content/cq:lastReplicationAction==ACTIVATE" to the conditions in the workflow launcher fixed the issue.

View solution in original post

7 Replies

Avatar

Level 3

just wanted to add, this is a on-prem AEM instance

Avatar

Community Advisor

@ASP_Corp invoke this workflow/ service from within an event listener that listens to replication events. when an asset is published, it will create a replication event that you can then listen to and invoke your workflow/logic to create asset versions. 

Refer to the below on how to create an event listener

https://aemhints.com/2020/11/08/event-listener-in-aem-6-5/

 

 

Avatar

Level 3

@Harwinder-singh , thank you for the reply, but isnt there a simple way to restrict my workflow launcher via conditions, exclusion..etc??. like trigger my workflow via launcher when the quick publish or manage publish is clicked?, writing a class for a rather simple scenario is a bit overkill i think.

Avatar

Community Advisor

@ASP_Corp considering extensibility in mind, i doubt if that is an overkill. Also, when you plan to move to AEM as cloud service, you will have to switch to post processing workflows instead of launcher based implementations. Food for thought.

Avatar

Community Advisor

Hi @ASP_Corp ,

 

Please find this Workflow Launcher Configuration here , It helps you to control launcher with Conditions. you might not required to write class afterall.

 

Hope it helps,

 

Thanks,

Aditya Chabuku

Avatar

Level 3

Hi @Aditya_Chabuku , this is just a general configuration for workflow launcher, iam looking at specific configuration so that my workflow gets triggered only when the asset is published. thank you.

 

@Harwinder-singh , agreed. and this is one of the reasons our clients are cautions to migrate to AEM cloud.

Avatar

Correct answer by
Level 3

I found out the solution. adding this "jcr:content/cq:lastReplicationAction==ACTIVATE" to the conditions in the workflow launcher fixed the issue.