Expand my Community achievements bar.

SOLVED

Event filter in Event Handler

Avatar

Level 3

I'm creating an event handler which will run a workflow when an asset is created/uploaded in AEM. I implemented the below filter but multiple events are getting triggered for multiple resource types (original asset and renditions). Is there a way to add a resource type filter so that it is only triggered when resource type is "dam:Asset"?

 

 

@Component(service = EventHandler.class, immediate = true, property = {
Constants.SERVICE_DESCRIPTION + "=DAM Asset Events ",
EventConstants.EVENT_TOPIC + "=org/apache/sling/api/resource/Resource/ADDED",
EventConstants.EVENT_FILTER + "= (path=/content/dam/*)" })

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@ReddyIshanvi Based on the use case, I think the best approach would be using the Workflow Launchers, which triggers the workflow when an asset is uploaded, where you can configure the NodeType, path globbing, and exclude properties and conditions. Also, you have the option to deactivate through UI. 

Please check the OOTB workflow launchers here - http://localhost:4502/mnt/overlay/cq/workflow/admin/console/content/launchers.html 

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

@ReddyIshanvi Based on the use case, I think the best approach would be using the Workflow Launchers, which triggers the workflow when an asset is uploaded, where you can configure the NodeType, path globbing, and exclude properties and conditions. Also, you have the option to deactivate through UI. 

Please check the OOTB workflow launchers here - http://localhost:4502/mnt/overlay/cq/workflow/admin/console/content/launchers.html 

Avatar

Level 3

As per your requirements, recommended way is to use workflow Launchers rather Event Handler.

  • Select the resource type as dam:Asset
  • Add condition based on Node modify
  • Enable the workflow which you want to invoke.