Working with Liferay Object Actions

Liferay supports multiple events like add, update, delete, and Standalone on objects which helps organizations to build complete flow using objects.

Low code and no code development are handy for developing a website without a technical background. Liferay came with the Object concept, which is able to generate the persistence and service layers by just defining the required fields from the Liferay control panel. In this blog, here are some essential points from the objects.

Triggers for Object Actions

  • On After Add
    • When records are added to the object definition, this action will be invoked.
    • This action will be invoked even if the object entry is saved as a draft.
  • On After Update
    • When records are updated for object definitions, this action will be invoked.
    • This action will be invoked every time the record is updated.
  • On After Delete
    • When records are deleted, this action will be invoked.
  • Standalone
    • Standalone action will provide the flexibility to run this action whenever we want.
    • Once a record is created, action can be called from the widget or headless API.
  • On After Attachment Download
    • This action will be called when the attachment is downloaded for any object entries.
    • This action will be invoked every time the attachment is downloaded.

Types of Object Action

  • Add an Object Entry
    • This type of action can be used when we want to add an object entry when the record is added.
    • Suppose that every time an employee (object) entry is created, we want to create a user account for that employee. At this time we can choose this action type and add an object entry to the user object.
  • Update an Object Entry
    • This type of action can be used when we want to update the object entry that was added/updated.
    • Suppose we have first name and last name fields in the object, and we want to populate the full name automatically. We can utilize this type of action to achieve this use case.
  • Groovy Script
    • This type of object action lets us run a piece of Java code.
    • This type of action is not available in Liferay SAAS.
  • Notification
    • We can send a notification (email or portal notification) using object actions.
  • Webhook
    • We can call webhook events with this type of action.
    • Let's say when an object entry is created, we want to create a task in JIRA; we can use a webhook at this time.

Conditions

  • Conditions can be defined to validate the records before calling any predefined actions.
  • We can utilize the expression builder to build the conditions.
  • If the condition is not passed, Liferay will not call the object action.