Calculated Fields in Liferay 7.4: Aggregation, Auto-Increment & Formula Guide


Introduction
Liferay 7.4 Objects provide a powerful low-code capability to build business applications without writing custom modules. While basic object fields allow users to store data, Calculated Fields take your application to the next level by generating dynamic, read-only values based on logic or related data.
Instead of relying only on manual user input, calculated fields allow you to :
- Automatically generate identifiers
- Calculate totals and metrics
- Summarize related records
- Build intelligent data-driven applications
In this guide, we will explore each type in detail with real-world examples and exact navigation steps.
Applicable Liferay Versions
Aggregation - Liferay 7.4 U47+/GA47+
Auto-Increment - DXP 2024.Q1+/Portal GA112+
Formula - Liferay DXP 2023.Q4+/Portal GA102+
Prerequisites
You should understand basic object creation.
Overview
Liferay Objects (introduced and enhanced in Liferay 7.4) allow you to build structured business applications without writing custom Java modules. Objects act like database-backed entities where you can define fields, relationships, validations, actions, and permissions all from the UI.
By combining relationships and calculated fields, you can transform simple data entry forms into fully functional business applications.
Where to Access Objects
Navigation Path:
Application Menu → Control Panel → Objects
1. Aggregation Fields
An Aggregation Field calculates a read-only value from related object entries.
It works only when :
- There is a relationship (One-to-Many or Many-to-Many)
- Related object contains numeric fields
- You want to summarize related data
Supported Functions :

Example : Ticketing System
You have two Objects :
- Ticket
- Ticket Response
Each Ticket can have multiple Responses.
Each Response contains : Response Time (Decimal), Hours Spent (Decimal)
Now you want to :
- Count total responses
- Calculate total hours spent
- Find average response time
- Show minimum & maximum response time
Step 1 : Create Objects
Create Ticket Object
Add fields :
- Ticket Title – Text
- Description – Long Text
- Status – Picklist (Open, In Progress, Closed)
Publish it.
Create Ticket Response Object
Add fields :
- Response Message – Long Text
- Response Time (Hours) – Decimal
- Hours Spent – Decimal
- Responder Name – Text
- Response Date – Date
Publish it.
Step 2: Create Relationship
Create Ticket Object
Navigation: Ticket → Relationships → Add Relationship
Select :
- One-to-Many
- Related Object : Ticket Response
Publish.
This creates a relationship table internally.
Step 3: Add Aggregation Field
Go to : Ticket → Fields → Add Field
Select : Field Type → Aggregation
Now configure :
- Relationship : Select Ticket → Ticket Response
- Function : Count / Sum / Avg / Min / Max
- Target Field : Choose numeric field (if required)
Example Fields :
- Total Responses – Aggregation (Count)

- Total Hours Spent – Aggregation (Sum → Hours Spent)

- Average Response Time – Aggregation (Average → Response Time)
- Minimum Response Time – Aggregation (Min → Response Time)
Publish the object.

Create a Ticket entry and then add multiple related Ticket Response entries with values such as response time and hours spent. The aggregation fields in the Ticket automatically calculate totals, averages, and other metrics based on these related responses.


Filtering Aggregation
You can add filters like below :

Technical Behavior of Aggregation Fields
- Value is read-only
- Automatically updates when related entry changes
- Stored in object table
- Indexed in Elasticsearch
2. Auto-Increment Fields
Auto-Increment field generates unique, sequential values automatically for each new object entry. It is read-only, automatically generated and can include prefix and suffix.
| Prefix | Starting Value | Suffix | Suffix | |
|---|---|---|---|---|
| Example 1 | INV- | 1000 | none | INV-1001, INV-1002, INV-1003… |
| Example 2 | none | 0 | none | 0, 1, 2, 3... |
| Example 3 | none | 1 | -TKT | 01-TKT, 02-TKT… |
Example : Invoice System
Create an Invoice Object.
Step 1: Create Objects
Navigation: Invoice Object → Fields → Add Field

Field Type : Auto-Increment
Starting Value : 1000
Prefix : INV-
Suffix : (optional)
Publish.
Now when you create entries, Invoice Number will be generated automatically.

Do NOT change format after production. Changing Prefix, Suffix, Starting value may cause inconsistency in records.
Import & Export Behavior
When working with data migration :
Rules for Successful Import
| Condition | Required |
|---|---|
| Unique External Reference Code (ERC) | ✔ |
| Unique Auto-Increment Value | ✔ |
What Happens If Rules Are Broken
- Duplicate values → Import fails
- Conflicts → Partial import
- Inconsistent format → Some records skipped
Formula Fields
What is a Formula Field?
Formula fields calculate values using numeric fields within the same object entry.
Supports :
- Addition (+)
- Subtraction (-)
- Multiplication (*)
- Division (/)
Works only within the same object (not across relationships).
Real-Time Example : Project Cost Calculation
Create a Project Object → Fields → Add Field
Fields :
- Hours Worked (Decimal)
- Hourly Rate (Decimal)
- Tax Percentage (Decimal)
- Base Cost (Formula)

You can define Integer or Decimal as an output type.
Formula to calculate the Base cost:
Base Cost: (hoursWorked * hourlyRate) * (1 + taxPercentage/100)

Click on Edit to add the formula.

Save the object, then create a new entry. The cost will be calculated automatically upon saving.

Technical Behavior
- Evaluated at runtime
- Read-only
- Updated when referenced field changes
- Indexed for search
When to use
| Feature | Aggregation | Auto-Increment | Formula |
|---|---|---|---|
| Cross-object | Yes | No | No |
| Uses relationship | Yes | No | No |
| Uses numeric fields | Yes | No | Yes |
| Editable | No | No | No |
| Real-time calculation | Yes | At creation | Yes |
Common Mistakes to Avoid
- Using Aggregation without relationship
- Applying too many filters
- Changing auto-increment format after go-live
- Dividing by zero in formula field
Conclusion
Calculated fields transform Liferay Objects from simple data storage into intelligent, dynamic business applications. You can build low-code enterprise solutions directly inside Liferay 7.4 without writing custom Java modules. Instead of making usCalculated Fields in Liferay 7.4 Object Users calculate values manually, let your object model do the work intelligently.