Mastering Data Modeling with Liferay Objects

Course Overview

Automating Clarity’s Distributor Notifications

So far, Clarity’s distributor management app has no automated notifications for entry events. This means administrators must check the object to learn of new submissions and inform applicants on the status of their applications manually. This strategy doesn’t scale and leaves room for human error, resulting in missed opportunities or poor user experience. In these exercises, you’ll automate notifications to streamline communication Clarity's distributor onboarding process.

Exercise: Adding Notification Templates

Setting up notifications begins with defining notification templates. These templates serve as blueprints for your notifications, specifying the content, design, and delivery method. Once defined, you can then use the template for notification actions in an object definition.

Clarity needs four notification templates for their distributor management app:

Event Recipient Type
Application Submitted Email User
Application Received Applicant Email
Application Approved Applicant Email
Application Denied Applicant Email

 

Here you’ll create these templates.

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

  2. Click Add (Add) and select User Notification.

  3. Scroll down to Definition of Terms and use the Entity drop-down menu to select the Distributor Application object.
    Select the Distributor Application object in the Definition of Terms.

    You can use these field references in the template to populate notifications dynamically with entry data. In the General Terms section are terms for referencing fields for the user that triggers the notification action.

  4. Scroll up to the Basic Info section and enter these values:

    Field Value
    Name Distributor Application Submitted, Admin, User
    Description Sends user notifications to an administrative role whenever a distributor application is submitted.

    Scroll up to the Basic Info section and enter the values above.
  5. Enter these values for Settings:

    Field Value
    Name Role
    Role

    Business Development Manager

    Business Development Specialist


    Enter the values above for Settings.
     
  6. Enter this value for Content:

    Field Value
    Subject APP-[%DISTRIBUTORAPPLICATION_ID%]: [%DISTRIBUTORAPPLICATION_APPLICANTNAME%] submitted a distributor application for [%DISTRIBUTORAPPLICATION_BUSINESSNAME%].

    Enter the values above for Content.
     
  7. Click Save.

  8. Open your terminal and go to the client-extensions/liferay-clarity-batch-create-notification-templates/ folder in your course workspace.

  9. Run this command to deploy the batch client extension.

    blade gw clean deploy
  10. Verify it deploys successfully.

    2024-12-15 03:26:47.671 INFO  [fileinstall-directory-watcher][BundleStartStopLogger:68] STARTED liferayclaritybatchcreatenotificationtemplates_7.4.13 [1491]
     
  11. Verify three new email notification templates appear.
    Verify three new email notification templates appear.

    These templates provide email notifications to applicants, keeping them informed about the status of their applications.

  12. Review the contents of each template.

With the templates in place, you can use them for object notification actions.

Exercise: Adding Notification Actions

Clarity wants to improve visibility for new applications. They also want to automate updates for applicants, notifying them when their application is received, approved, or denied. Here you’ll add these notification actions 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 begin editing the Distributor Application object.

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

  4. Enter these values in the Basic Info tab:

    Field Value
    Action Label Application Submitted
    Action Name applicationSubmitted
    Description Notify the business development team of new distributor applications.
    Active Yes
  5. Go to the Action Builder tab and set these values:

    Field Value
    Trigger On After Add
    Condition N/A
    Action Notification
    Notification Template Distributor Application Submitted, Admin, User
  6. Click Save.
    Click Save.
     
  7. Repeat the above steps to create three more notification actions:
    Field Value
    Action Label Application Received
    Action Name applicationReceived
    Description Notify applicants when their applications are received.
    Active Yes
    Trigger On After Add
    Condition N/A
    Action Notification
    Notification Template Application Received, Applicant, Email
     
    Field Value
    Action Label Application Approved
    Action Name applicationApproved
    Description Notify applicants when their applications are approved.
    Active Yes
    Trigger On After Update
    Condition applicationState == "approved" AND status == 0
    Action Notification
    Notification Template Application Approved, Applicant, Email
     
    Field Value
    Action Label Application Denied
    Action Name applicationDenied
    Description Notify applicants when their applications are denied.
    Active Yes
    Trigger On After Update
    Condition applicationState == "denied" AND status == 0
    Action Notification
    Notification Template Application Denied, Applicant, Email
  8. Verify the actions work by creating and resolving a new distributor application entry.
    Click Save.

With these notification actions in place, Clarity's distributor management app now automatically notifies the relevant users at each stage of the application process.

Conclusion

Great! You’ve successfully implemented automatic notifications for Clarity’s distributor management app. These enhancements streamline communication and improve the user experience for Clarity's administrators and applicants. Next, you’ll explore how to use object actions to automate entry creation and updates.

  • Exercise: Adding Notification Templates

  • Exercise: Adding Notification Actions

  • Conclusion

Loading Knowledge

Capabilities

Product

Education

Contact Us

Connect

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