Extending System Objects
Available Liferay 7.4 U72+/GA72+
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|
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).
You can add 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.
If the system object is in a many-to-many relationship or on the parent side of a one-to-many relationship, Liferay generates REST endpoints for querying and managing the relationship. This includes a GET endpoint for returning related object entries, PUT endpoint for relating entries, and DELETE endpoint for disassociating related entries.
In this example, the User system object is in a one-to-many relationship (
userRequests) with a custom object (
timeOffRequest). These endpoints appear in the
See Using Relationships REST APIs for an introductory tutorial.
You can add actions to system objects, triggered on events like adding, updating, or removing entries. The table below shows actions supported by system objects:
|Action Type||Supported in System Objects?|
|Add Object Entry||✔|
|Update Object Entry||✔|
See Defining Object Actions for more information.
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.