oo

Creating Objects

Liferay 7.4 2023.Q4+/GA102+

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 object drafts, editing them, and finally publishing them to create the new application.

Here you’ll learn how to create object definitions using the default Objects UI, but you can also create, manage, and extend object definitions using the Model Builder GUI. See Using the Objects Model Builder for more information.

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. To create a draft object,

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

    Note

    For Liferay 7.4 2023.Q4+/GA102+, you must also have the Object Folder > View permissions to access the Objects UI. See Objects Application Permissions for more information.

  2. Go to the desired object folder and click the Add button (Add Button).

  3. Provide these details for the 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 after publishing.

    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

Liferay 7.4 2023.Q3+/GA92+

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 Field 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 Link 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 link 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 Events.

  19. Beta Feature Enable or disable draft mode for object entries.

    While enabled, users can save entries as a draft and finalize them at a later time. Saving drafts does not trigger custom validations, workflow processes, or actions triggered by entry creation.

    note

    You can configure this setting at any time. Disabling draft mode does not change the status of existing entries.

  20. Enable or disable translation support for custom text fields.

    While enabled, you can enable translation for custom text fields, so end users can localize their input. See Localizing Object Definitions and Entries for more information.

  21. 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 link. 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

Liferay 7.4 U86+/GA86+

To prevent data loss and system conflicts, Liferay restricts these configuration options for object definitions after publishing:

  • Name
  • Scope
  • Account Restriction (if enabled)
  • Entry Translation

Liferay also restricts some custom field options (e.g., mandatory, unique values).

note

For Liferay 7.4 U85/GA85 and earlier versions, users cannot delete fields included in the object definition at the time of publishing.

Feature: