Expand my Community achievements bar.

SOLVED

Invoking a Worfklow within a custom event handler

Avatar

Former Community Member

Re: https://helpx.adobe.com/experience-manager/using/events.html

I'm creating an event handler which will run a workflow on some XML files when they are uploaded to the folder. Now I want this

to run automatically, so I got the basic lay out of the event handler working perfectly. However I want to run a workflow when each item is uploaded,

how would I go about invoking this to each file that is uploaded.

I was taking a look at the following article :

https://helpx.adobe.com/experience-manager/using/invoking-experience-manager-workflows-using.html

But can't seem to wrap my head around how I would implement this in an event handler.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Employee

As long as your event handler is a osgi component ( @component annotation above your class name), you should be able to get the workflowService instance by doing the following.

 @Reference
    private WorkflowService workflowService;
 

View solution in original post

3 Replies

Avatar

Level 10

Another option you have is to use workflow launcher. You can kickoff a workflow when content is modified /added in the JCR. We will be covering how to use Workflow launchers at next week's Ask the Community Experts. I just posted a discussion on how you can attend. 

Avatar

Correct answer by
Employee

As long as your event handler is a osgi component ( @component annotation above your class name), you should be able to get the workflowService instance by doing the following.

 @Reference
    private WorkflowService workflowService;
 

Avatar

Level 10

The node that is modified is used in the workflow - ie - assume you have a workflow that activates a page. Then you use workflow launcher to invoke this workflow when content under a certain path is modified. When you modify the page in under the path - it matches the conditions you set in the workflow launcher. Now that node (page) is used in the workflow and your page is activated.

Therefore - the node is used in the workflow all depends on how to setup workflow launcher.

See this community article for more information:

http://blogs.adobe.com/contentmanagement/tag/workflow-launcher/

Also - to learn more about workflows (including launcher)- sign up for next weeks ask the AEM community experts:

 http://scottsdigitalcommunity.blogspot.ca/2015/03/march-session-of-aem-ask-community.html