Creating Notification Templates
Available Liferay 7.4 U75+/GA75+
With Notification Templates, you can design automated email and user notifications for Liferay services. Each template identifies a sender, recipients, and message content. While designing the template, you can search supported entities and add field references that insert their data dynamically into emails.
Currently, notification templates only support object actions. However, Commerce Channels include built-in notification template capabilities for channel events. See Store Emails for more information.
To use email notifications, your instance must have a configured mail server. Once configured, you can access additional email notification settings at the instance level.
Adding Email Notification Templates
Open the Global Menu (
), go to the Control Panel tab, and click Notification Templates.
Click Add (
) and select Email.
You can use field references to populate messages dynamically with entry and user data. In the Definition of Terms section you can select an object definition to reference its supported fields. In the General Terms section you can find terms for referencing fields for the user who triggers the notification action. Use these reference terms in the template fields as desired. See Definition of Terms Reference for more information.
In Basic Info, enter a name and description for the template.
In Settings, enter contact information for the email sender and recipients.
To add multiple recipients, separate email addresses with a comma or space (e.g.,
[email protected],[email protected]
,[%TICKET_AUTHOR_EMAIL_ADDRESS%] [%CURRENT_USER_EMAIL_ADDRESS%]
).In Content, enter a subject, select an editor type, and create the body of the email.
For type, select Rich Text or FreeMarker Template.
(Optional) Select object attachment fields to include their assets in email notifications.
importantYou can only attach assets from object entries involved in the notification action.
Click Save.
Once created, you can use notification templates with object actions. See Defining Object Actions for more information.
Adding User Notification Templates
Open the Global Menu (
), go to the Control Panel tab, and click Notification Templates.
Click Add (
) and select User Notification.
You can use field references to populate messages dynamically with entry and user data. In the Definition of Terms section you can select an object definition to reference its supported fields. In the General Terms section you can find terms for referencing fields for the user who triggers the notification action. Use these reference terms in the template fields as desired. See Definition of Terms Reference for more information.
In Basic Info, enter a name and description for the template.
In Settings, determine the notification’s recipients.
You can use defined terms, user names, or user roles. To add multiple recipients, separate values with a comma or space (e.g.,
[%TICKET_AUTHOR_ID%]
,[%TICKET_R_ASSIGNEE_USERID%]
).In the Content section, enter the notification’s message.
You can use defined terms to populate values dynamically.
Click Save.
Once created, you can use notification templates with object actions. See Defining Object Actions for more information.
Definition of Terms Reference
You can use reference terms to access user and entry data, dynamically populating a template’s fields. You can reference any entries and users involved in the event triggering the notification action.
Consider a scenario with a custom Ticket object that is on the child side of a one-to-many relationship with the User system object. This relationship determines the ticket’s assignee. If you add a notification action to the Ticket object for notifying the assignee on entry update, the template used for this action can access data for both the updated ticket and the assignee.
Terms are available for both custom and default object fields.
You can only reference fields for entries and users directly involved in the event that triggers the notification action.
Default Terms for Current Entry
Use these terms to access information about the current object entry.
Label | Term |
---|---|
Author Email Address | [%OBJECTNAME_AUTHOR_EMAIL_ADDRESS%] |
Author First Name | [%OBJECTNAME_AUTHOR_FIRST_NAME%] |
Author ID | [%OBJECTNAME_AUTHOR_ID%] |
Author Last Name | [%OBJECTNAME_AUTHOR_LAST_NAME%] |
Author Middle Name | [%OBJECTNAME_AUTHOR_MIDDLE_NAME%] |
Author Prefix | [%OBJECTNAME_AUTHOR_PREFIX%] |
Author Suffix | [%OBJECTNAME_AUTHOR_SUFFIX%] |
Create Date | [%OBJECTNAME_CREATEDATE%] |
External Reference Code | [%OBJECTNAME_EXTERNALREFERENCECODE%] |
ID | [%OBJECTNAME_ID%] |
Modified Date | [%OBJECTNAME_MODIFIEDDATE%] |
Status | [%OBJECTNAME_STATUS%] |
Default Terms for Current User
Use these terms to access information about the current user triggering the notification action.
Label | Term |
---|---|
Current User Email Address | [%CURRENT_USER_EMAIL_ADDRESS%] |
Current User First Name | [%CURRENT_USER_FIRST_NAME%] |
Current User Prefix | [%CURRENT_USER_PREFIX%] |
Current User Last Name | [%CURRENT_USER_LAST_NAME%] |
Current User Middle Name | [%CURRENT_USER_MIDDLE_NAME%] |
Current User ID | [%CURRENT_USER_ID%] |
Current User Suffix | [%CURRENT_USER_SUFFIX%] |