Creating Objects

Creating Objects

Available Liferay 7.4+

Liferay Objects provides development capabilities in the Liferay UI. Using Objects, you can build fully integrated Liferay applications without writing any code or manually deploying modules. This process includes creating an initial draft of the object definition, editing the draft, and finally publishing it to create the new application. Publishing an object draft creates a fully integrated Liferay application that can be managed and extended at any time via the Objects admin page.

important

Liferay creates database tables when you publish object definitions, so you cannot use Objects with the high security database practices described in Database Configurations.

Creating Object Drafts

Object drafts are application templates that store the necessary data for creating an object application. Follow these steps to create an object draft:

  1. Open the Global Menu (Global Menu), go to the Control Panel tab, and click Objects.

  2. Click the Add button (Add Button).

  3. Provide these details for your object draft.

    Label: Identifies the object in the Objects admin and supported application contexts (e.g., Workflow, Display Page Templates, Forms).

    Plural Label: Determines the display name for the object application in the UI.

    Object Name: Determines the object’s definition.name and cannot be changed once the object is published.

    Enter a Label, Plural Label, and Name for the object draft.

  4. Click Save.

Once saved, a blank object draft is created without any configurations or data elements. You can view the draft in the Objects admin alongside system objects. To finish the creation process, you must edit the draft and then publish it to your Liferay instance.

You can view the new object draft in the Objects admin.

Editing Object Drafts

Before publishing an object, you can add elements and configure its settings. This includes adding fields, defining validations, setting a scope for its data, and more.

note

Whenever you add a field, relationship, or layout, the object draft is saved automatically. However, any unsaved changes in the Details tab are lost if you navigate to other tabs.

Follow these steps to edit the object draft:

  1. From the Objects admin page, click the newly created object draft to begin editing it.

    Object features and configuration options are organized into the following tabs: Details, Fields, Relationships, Layouts, Actions, Views, Validations, and State Manager.

    Object features and configuration options are organized into eight tabs.

  2. Click the Fields tab to add custom fields. Each field represents a database column for storing specific types of values. See Adding Fields to Objects.

    By default, all objects include these system fields: Author, Create Date, External Reference Code, ID, Modified Date, and Status.

    Add fields to the object from the Fields tab.

  3. (Optional) Click the Relationships tab to add relationships. Relationships are connections between object definitions that you can use to link their entries. See Defining Object Relationships.

    Add relationships to the object from the Relationships tab.

  4. (Optional) Click the Layouts tab to add layouts. Object layouts determine how fields and relationships appear when creating and viewing object entries. See Designing Object Layouts.

    note

    If you do not add a custom layout and set it as default, the object uses an automatically generated layout for its entries. This layout has a single tab that displays all object fields in alphabetical order and does not display relationships. To display relationships, you must create a custom layout with a dedicated relationships tab.

    Add custom layouts to the object from the Layouts tab.

  5. (Optional) Click the Actions tab to add custom actions. Each action defines an operation that runs automatically according to a set trigger. See Defining Object Actions.

    Add custom actions to the object from the Actions tab.

  6. (Optional) Click the Views tab to add custom views. Object views determine how entries are displayed in the object’s application page. See Designing Object Views.

    Add custom views to the object from the Views tab.

  7. (Optional) Click the Validations tab to add validations. Each validation sets rules for determining valid field entries. See Adding Custom Validations.

    Add custom validations to the object from the Validations tab.

  8. (Optional) If you’ve added a state field to the draft, click the State Manager tab to define its flow. See Adding and Managing Custom States.

    Define flows for state fields in the State Manager tab.

  9. Click the Details tab to configure the object draft.

  10. (Optional) Change the name, label, or plural label for the object.

    Change the name, label and plural label for the object.

  11. Select an Entry Title. This determines the field used to identify the object’s entries in the UI (e.g., relationship fields). By default, objects use the ID field.

    Once a field is added to an object, you can select it as the Entry Title.

  12. Select an object scope. This determines how the object’s data is stored.

    Company (default): When scoped by Company, the object’s data is stored per Liferay instance.

    Site: When scoped by Site, the object’s data is stored per Site.

  13. Select a Panel Category Key to determine where the definition appears in Liferay.

    For company-scoped objects, select tab and category in the Global Menu (Global Menu).

    For site-scoped objects, select a section in the Site Menu (Site Menu).

    You can leave this value blank if you don’t want to display the application in a UI menu.

    Select a scope and panel category key for the object.

  14. Configure account restriction to restrict access to object entries by account. You can only configure this setting before publishing.

    This option only appears if the object is on the child side of a one-to-many relationship with the Account system object. See Restricting Access to Object Data by Account.

    Determine whether to limit restrict access to object entries by account.

  15. Show or hide the object’s page widget.

    While enabled, you can add the object’s widget to site pages. See Deploying Object Widgets in Sites.

  16. Enable or disable categorization for object entries.

    While enabled, you can add categorization blocks to fields tabs in custom layouts. See Adding Categorization to Fields Tabs. Additionally, you can attach metadata to the object entries by adding the tags and categories fragments in form containers.

  17. Enable or disable comments for object display pages.

    While enabled, you can use the Page Comments widget in entry display pages. See Creating Display Page Templates for Objects.

  18. Enable or disable history for object entries.

    While enabled, Liferay keeps a history of entry events that you can view in the Audit application or via REST API calls. See Auditing Object Definition Events.

    important

    For 7.4 U72+/GA72+, you can configure this setting at any time. For prior versions, you can only configure this setting before publishing.

  19. Click Save.

Once you’ve finished configuring and editing the draft, you can publish it.

Publishing Object Drafts

Publishing an object creates and activates your new application. When activated, users can access it in the Liferay UI according to its scope and panel category key. Before publishing your object, review the following information to understand the consequences of publishing a draft.

What Happens During Publishing

The publishing process includes the following operations:

  • A database table is created for the object with the draft’s data definitions.

  • A new Headless API is automatically created for CRUD operations.

  • A collection provider is created for displaying the object’s entries.

  • A page widget is created for the object.

  • The object is integrated with Info framework, so you can select the object as a content type for a display page template

  • The object is integrated with the Permissions framework, so you can manage permissions for the new application and its resources.

  • The object is integrated with the Workflow framework, so you can configure a custom workflow for the object.

  • The object is integrated with Forms, so you can select the object as a data storage option.

Configuration Restrictions for Published Objects

For 7.4 U26+/GA26+

To prevent data loss and system conflicts, some configuration options are removed for objects after publishing.

  • The name and scope of a published object cannot be changed.

  • Any fields included in an object at the time of publishing cannot be removed.

  • Most configuration options for published fields and relationships cannot be changed.

You can still edit and localize labels for objects, fields, and relationships after publishing, but most configuration options are removed. For objects, you can change the Panel Category Key as well as add new fields, relationships, and layouts. For relationships, you can configure its Deletion Type.

note

For Liferay 7.4 U25/GA25 and earlier versions, users cannot delete published object definitions or remove relationships included in an object at the time of publishing.