Extending System Objects
Available Liferay 7.4 U46+/GA46+
With Liferay Objects, you can extend supported system services. Currently, only these services are integrated with the Objects framework: Account, Commerce Order, Commerce Product, Commerce Product Group, Postal Address, and User.
The Postal Address object is only used to store account addresses. For this reason, you can only relate it to custom objects that are related to the Accounts object. See Using System Accounts with Custom Objects for more information.
When extending system objects, you can add fields, relationships, actions, and validations to them.
Feature | System Objects | Custom Objects |
---|---|---|
Fields | ✔ | ✔ |
Relationships | ✔ | ✔ |
Layouts | ✔ | |
Actions | ✔ | ✔ |
Views | ✔ | |
Validations | ✔ | ✔ |
Adding Fields
You can add fields to system objects. The additional database columns are added to a separate database table that uses the service’s original table name with _x
appended to it (e.g., AccountEntry_x
). System objects support all available field types. Since system objects do not support custom layouts or views, you can only access these custom fields via Headless APIs. See Adding Fields to Objects for more information.
Liferay’s Custom Fields application is for adding fields to most Liferay system applications using the Expando framework. Objects does not support the Expando-based custom fields, so you cannot use them with Objects features (e.g., relationships, actions, and validations).
Adding Relationships
You can create relationships between system and custom objects to link their entities. System objects support both one-to-many and many-to-many relationships. See Defining Object Relationships for more information.
Since system objects don’t support custom layouts, you cannot add layout tabs to the object for displaying many-to-many relationships or the parent side of a one-to-many relationship.
Adding Actions
You can add actions to system objects, to be triggered when entries are added, updated, or removed. The table below shows actions supported by system objects:
Action Type | Supported in System Objects? |
---|---|
Webhook | ✔ |
Groovy Script | ✔ |
Notification | ✔ |
Add Object Entry | ✘ |
Update Object Entry | ✘ |
See Defining Object Actions for more information.
Adding Validations
You can add Groovy and Expression Builder validations to system objects. When triggered, these validations check for valid field entries and show custom error messages for invalid entries. Currently, Objects only supports validations for a system object’s default fields and does not support validations for its custom fields. See Adding Custom Validations for more information.