Guide for Execution of Custom Entity Kaleo Workflow in Liferay DXP Including Coding Part

Custom Entity Kaleo Workflow Integration in Liferay DXP Including Coding Part Workflow Engines have their own precise patterns starting from verification of the current status to determining the authority of users to executing condition script. The developer’s methodology to integrate it with the application defines the critical success factor of its optimum usability. Hereby, I am sharing one of my experiences of implementing the Kaleo workflow engine in a Liferay development process.

Liferay supports the Kaleo workflow engine already deployed in its server bundle as well as available at the Liferay marketplace. Not only that, Kaleo substantially has out-of-the-box unification with Liferay DXP’s functional characteristics for the creation of roles, users, and organizations. Hence, I opted for Kaleo for the project we are discussing as the used case.

Project Details:

  • A Liferay Portal Development project for building a domain-specific web-based collaboration platform similar to PeoplePerHour.com or Guru.com

  • User Details:
liferay kaleo workflow tutorial

Kaleo Workflow with the Custom entity "ABCTask"

To implement the above-described workflow in my Liferay Application Development process, I created a custom entity "ABCTask" followed by workflow inception programmatically. I preferred dynamic navigation from one node to other instead of using the UI provided by Liferay DXP.

How to code for the actual execution of the Kaleo workflow

Know your Nodes first before you connect them

As a developer, we consider workflow to be a sensible connection between different nodes. Nodes can be:

liferay kaleo workflow tutorial

How to create Workflow Definition?

The creation of workflow definition (XML file) is an in-depth topic. I would suggest you be very clear about it. You can refer to the following link for the same.

Link:- https://dev.liferay.com/discover/portal/-/knowledge_base/6-2/creating-new-workflow-definitions 

Coding Details

As developers, we are aware of the fact that when it comes to executing a workflow, all nodes are a task.

[A] Creation of Workflow Instance

When User A creates ABCTask, we need to start the workflow instance of the "ABCTask" entity using the Workflow API provided by Liferay. The coding part is displayed below. 

 Create Workflow Definition Link such as:

liferay kaleo workflow tutorial

To enable a workflow for the custom entity, we have to make that entity an asset:

Custom Entity Kaleo Workflow in Liferay DXP

Start workflow instance:

Custom Entity Kaleo Workflow in Liferay DXP

When the workflow gets started, it will be the initial state, known as the CREATED state. The workflow will be executed to the Task node of the workflow. The user input will be required at the Task node.

[B] Obtaining Workflow Task

When User B sends the proposal to User A and User A approves it, the state of Entity has to be moved from “Start” to “Approved”. Liferay’s API can be used for moving workflow tasks from one state/task to another state/task.

Of course, without completion of the existing workflow task, you cannot move to another Task node. You can obtain Workflow Tasks from workflow logs. Please find the code snippet to obtain the workflow task and complete that task below

Workflow Instance is required to manage workflow operations:

Custom Entity Kaleo Workflow in Liferay DXP

[C] Obtaining the latest workflow taskId from logs:

Custom Entity Kaleo Workflow in Liferay DXP

[D] Completion of the Workflow Task:

You need the next transition name to execute other nodes.

liferay dxp workflow


Though the technology world offers us unlimited tools to create business-friendly software applications, optimum utilization of Workflow Engines for desired process management demands individual creativity from a developer. This project enhanced my individual skills as a developer by driving my creative logic to the next level.  

Author of This Post

Author Bio: Namee Jani is a Passionate Digital Marketing Strategist working with Azilen Technologies. She is Certified in Google Adwords & Analytics and adores catching new trends and techniques prevalent in the online marketing world.
Previous Post
Next Post

post written by:

Hi, I’m Ghanendra Yadav, SEO Expert, Professional Blogger, Programmer, and UI Developer. Get a Solution of More Than 500+ Programming Problems, and Practice All Programs in C, C++, and Java Languages. Get a Competitive Website Solution also Ie. Hackerrank Solutions and Geeksforgeeks Solutions. If You Are Interested to Learn a C Programming Language and You Don't Have Experience in Any Programming, You Should Start with a C Programming Language, Read: List of Format Specifiers in C.
Follow Me