Mastering Data Modeling with Liferay Objects

Course Overview

Adding Fields to Clarity's Distributor Management App

In this article, you’ll continue implementing Clarity’s distributor management app. This involves creating picklists and adding new business fields to the Distributor Application object. Finally, you’ll create a basic view for displaying distributor application entries.

Exercise: Adding Basic Fields

Here you’ll add additional basic fields to the Distributor Application object.

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

  2. Go to the Distributor Management folder and select View in Model Builder.

  3. For the Distributor Application object, click Add Field or Relationship, and select Add Field.

    In the Model Builder UI, add a field for the Distributor Application object..

  4. Enter these values and click Save.

    Field Value
    Label Comments
    Field Name comments
    Type Long Text
    Enable Entry Translation No
    Mandatory No
  5. Repeat the above steps to add this field to the Distributor Application object.

    Field Value
    Label Business License
    Field Name businessLicense
    Type Attachment
    Request Files Upload Directly from the User’s Computer
    Show Files in Documents and Media Yes
    Mandatory No
  6. Open a terminal window and go to this folder in the course workspace: liferay-course-objects/client-extensions/liferay-clarity-batch-create-distributor-object-fields.

  7. Run this command to deploy a batch client extension and add the remaining basic fields to Clarity’s distributor management app:

    blade gw clean deploy
    
  8. Verify the fields appear in the Distributor Application and Application Evaluation objects.

    If the fields do not appear, ensure both objects have the correct ERC:

    Object ERC
    Distributor Application D4B8_DISTRIBUTOR_APPLICATION
    Application Evaluation D4B8_APPLICATION_EVALUATION

Together, these fields can help Clarity assess potential distributors.

Exercise: Creating Picklists

Here you’ll create several picklists for use in Clarity’s distributor management app.

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

  2. Click Add (), enter Product Types for name, and click Save.

    Click Add, enter Business Types for name, and click Save.

  3. Begin editing the picklist.

  4. Click Add () and add these items to the picklist:

    Name Key
    Eyeglasses eyeglasses
    Sunglasses sunglasses
    Contacts contacts
    Lenses lenses

    Edit the picklist and add new items.
  5. Edit each item and set their ERCs to these values:

    External Reference Code
    PRODUCT_TYPE_EYEGLASSES
    PRODUCT_TYPE_SUNGLASSES
    PRODUCT_TYPE_CONTACTS
    PRODUCT_TYPE_LENSES

    Edit each item and set their ERCs to the referenced values.
  6. Change the picklist’s ERC to PRODUCT_TYPES.
    Change the picklist’s ERC to PRODUCT_TYPES.

  7. Click Save.

  8. In your terminal window, go to this folder in the course workspace: liferay-course-objects/client-extensions/liferay-clarity-batch-create-picklists.

  9. Run this command to deploy the client extension and add the remaining picklists for Clarity’s distributor management app:

    blade gw clean deploy
    
  10. Verify the new picklists appear.

    Verify the new picklists appear.

With these picklists in place, you can now add single select and multi-select fields with predefined options to Clarity’s distributor management app.

Exercise: Adding Picklist Fields

Here you’ll use the picklists you created in the previous exercise to add fields with predefined options to the Distributor Application object.

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

  2. Go to the Distributor Management folder and select the Distributor Application object to begin editing it.

  3. Go to the Fields tab and click Add ().

  4. Enter these values and click Save.

    Field Value
    Label Products of Interest
    Field Name productsOfInterest
    Type Multiselect Picklist
    Picklist Product Types
    Mandatory No

    ​​Enter the new values and click Save.
  5. In your terminal window, go to this folder in the course workspace: liferay-course-objects/client-extensions/liferay-clarity-batch-create-distributor-object-picklist-fields.

  6. Run this command to deploy the client extension and add the remaining picklist fields to Clarity’s distributor management app:

    blade gw clean deploy
    
  7. Verify the picklist fields appear in the Distributor Application and Application Evaluation objects.

Great! Now Clarity’s distributor management app has all the necessary fields for capturing applicant data.

Exercise: Creating a Basic View

The Distributor Application object has expanded to include numerous fields, making the default display cumbersome and inefficient. Here you'll create a custom view to simplify the Distributor Application's table.

  1. While editing the Distributor Application object, go to the Views tab.

    While editing the Distributor Application object, go to the Views tab.

  2. Click Add ().

  3. Enter the name Basic View and click Save.

    Enter the name Basic View and click Save.

  4. Click the new view to begin editing it.

  5. In the Basic Info tab, check Mark as Default.

    In the Basic Info tab, check Mark as Default.

  6. Go to the View Builder tab and click Add Column.

    Go to the View Builder tab and click Add Column.

  7. Check the following fields and click Save.

    • ID

    • Applicant Name

    • Business Name

    • Create Date

    • Status

      Check the following fields and click Save.

  8. Click Save.

Great! Now distributor application entries will be displayed using the view you created. Basic views like this are best suited for testing and administration cases where user experience and site integration are not important.

Conclusion

Congratulations! You have improved Clarity’s distributor management app by adding several new fields, along with a basic view. Next, you’ll learn how you can add validations to ensure data integrity.

  • Exercise: Adding Basic Fields

  • Exercise: Creating Picklists

  • Exercise: Adding Picklist Fields

  • Exercise: Creating a Basic View

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

Powered by Liferay
© 2024 Liferay Inc. All Rights Reserved • Privacy Policy