Adding Fields to Clarity's Distributor Management App

A well-designed object captures every piece of information your application needs to fulfill its purpose. Clarity needs to expand their distributor management app to store additional business information and applicant selections from lists of predefined options. In these exercises, you'll add both basic and picklist fields to Clarity’s object definitions. Then, you’ll also add a custom object view for testing purposes.

Exercise: Adding Basic Fields

To evaluate distributor applicants effectively, Clarity wants their data model to capture additional applicant details, including comments and business documents. Here, you’ll add fields manually and using a batch client extension as the Clarity Admin user.

  1. Sign in using these credentials:

    • Username: admin@clarityvisionsolutions.com

    • Password: learn

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

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

  4. 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..

  5. Enter these values and click Save.

    Field Value
    Label Comments
    Field Name comments
    Type Long Text
    Enable Entry Translation No
    Mandatory No
  6. 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
  7. Open a terminal window and navigate to the client-extensions/liferay-clarity-batch-create-distributor-object-fields/ folder in your course workspace.

  8. 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
    
  9. Verify the fields appear in the Distributor Application and Application Evaluation objects.
    If the fields don't appear, ensure both objects have the correct ERC:

    • Distributor Application: D4B8_DISTRIBUTOR_APPLICATION

    • Application Evaluation: D4B8_APPLICATION_EVALUATION

Together, these fields can help Clarity assess potential distributors.

Exercise: Creating Picklists

Free-form text fields can lead to typos and inconsistent data when capturing categorized information. To ensure data uniformity across applications, Clarity needs to define standardized lists that applicants can choose from (e.g., product categories, business types). Here, you’ll create picklists manually and using a batch client extension as the Clarity Admin user.

  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.

  7. Click Save.

  8. Open a terminal window and navigate to the client-extensions/liferay-clarity-batch-create-picklists/ folder in your course workspace.

  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

Once you’ve created a picklist, you can use it as a field in your object definition. Clarity needs to add both single-select and multi-select fields to their distributor management app. Here you’ll add field manually and using a batch client extension as the Clarity Admin user.

  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. Open a terminal window and navigate to the client-extensions/liferay-clarity-batch-create-distributor-object-picklist-fields/ folder in your course workspace.

  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

Clarity’s objects now include numerous fields, making the default table cumbersome and inefficient to browse during testing. With Liferay, you can create views that control which columns appear in the table without affecting the underlying data. Here, you'll create a simplified, basic view as the Clarity Admin user.

NOTE
Object views are best suited for internal testing or proof of concept and are not intended for end-user displays. You’ll learn how to build object UIs in Module 6.
  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.

  9. Verify your configuration works by creating a Distributor Application entry and verifying its table only displays your selected fields.

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

A complete data model is the foundation of any effective business application. With the new fields, picklists, and basic view in place, Clarity's distributor management app can now capture the information required to evaluate applicants thoroughly and consistently.

Next, you’ll learn how you can add validations to ensure data integrity.

Loading Knowledge