Documentation

Defining Object Relationships

Available: Liferay DXP/Portal 7.4+

Relationships are connections between Objects that link their entities. You can add relationships to any published or unpublished custom Object.

Relationship Types

Objects provides two types of relationships:

One to Many: You can relate one of the current Object’s entities to multiple entities of another Object. When selected, a new field is added to entities on the child side of the relationship (i.e., the ‘many’ side), while a table is added to the ‘parent’ side (i.e., the ‘one’ side). On the child side, the new field can be added to a Fields Tab in the Object’s custom layout and relates its entities to a single entity on the parent side of the relationship. On the parent side, the new table can be added to a Relationships Tab in the Object’s custom layout and lists all entities related to the current parent entity.

Many to Many: You can relate multiple entities from the current Object to multiple entities in another Object. When selected, a new database table is created for both sides of the relationship. This table can be added to a Relationships Tab in either Object’s custom layout and is used to list all related entities.

Important

You must create a custom layout to display relationships for Object entries. See Designing Object Layouts for more information.

Adding New Relationships

Follow these steps to add relationships to an Object:

  1. Open the Objects portlet.

  2. Select the desired Object.

  3. Click the Relationships tab and select the Add button (Add Button).

    Click on the Add button in the Relationships tab, then enter a label abd name, and select a relationship type and the desired Object.

  4. Enter a Label and Relationship Name.

    Label: Identifies the relationship in the Objects UI and can be localized after the relationship is created.

    Relationship Name: Determines the relationship’s name in the back-end and uses camel case. Once the relationship is published, this value cannot be changed.

  5. Select a relationship Type: One to Many or Many to Many.

    Note

    If you intend to relate entries within the same Object, you must use the One to Many type.

  6. Select an Object to relate to the current Object.

  7. Click on Save.

    After clicking Save, the saved relationship is listed in the Relationships tab.

Once saved, the new relationship can be added to custom layouts for the related Objects. You can then use the relationship fields and tables to relate Object entries to one another.

Important

While the Object is a draft, you can edit and remove relationships from the parent side. Once an Object is published, however, any existing or newly added relationships cannot be removed. Users can only configure a relationship’s label and deletion type.

Configuring Deletion Type

After a relationship is saved, you can configure its deletion type. This setting determines how entry deletion is handled when the entry is related to another entry, and it is only available after a relationship is created.

After creating a relationship, you can configure its deletion type.

Available options include Prevent, Disassociate, and Cascade.

Prevent (Default): Entries on the parent side cannot be deleted if they are related to any child entries.

Disassociate: Entries on the parent side can be freely deleted without affecting any related child entries.

Cascade: Entries on the parent side can be freely deleted; deleting a parent entry also deletes any related child entries, provided the user has the requisite permissions for the child Object.