April 26, 2020
Estimated Post Reading Time ~

Creating Custom CQ/AEM Workflow Process Step

It's no secret that CQ/AEM Workflows are quite powerful, but what happens when the default process steps aren't what you need? In a case like this, you need to create your own custom process step. In this article, I will detail the steps you need to take in accomplishing this.
1) This tutorial is going to be completed in java, drill down into the Java portion of your codebase, and create a java file.



2) Anytime I create something that is going to appear in the Felix Console I like to label it properly.



3) Now implement "WorkflowProcess" and override the "execute" method.



4) As you can see the "execute" method gives you 3 different variables to work with within the method.

WorkItem, This data type will hold most of your workflow data and can be used to get the workflow data. Please see the API here.

WorkflowSession, This data type allows you to control the workflow. Please see the API here.

MetaDataMap, A map of all workflow metadata. Please see API Here. here.
In this example, let's just get the current assignee and print it out to the log.



5) That's all we need on the code side of things, let's have a look at the GUI workflow interface CQ provides and create a simple workflow! Browse to http://localhost:4502/libs/cq/workflow/content/console.html and select "New" in the top left.



6) In the sidekick browse down to the "Workflow" category and drag and drop the "Process Step" into your workflow.



7) Double click on the "Process Step" and then select the "Process" tab. There will be a drop-down in that tab titled "Process", from that dropdown select the Process you just finished writing. (Note: Keep in mind the process will show the same name that you put into the "process.label" property in the Felix annotations up above).



8) That's it! You've created your own custom workflow process step and implemented it into your CQ5/AEM6 workflow. Great work!


By aem4beginner

No comments:

Post a Comment

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