Relating Object Entries
After defining an object relationship, you can relate entries in two ways: the Liferay UI or relationship REST APIs. Here you’ll practice relating evaluations and applications via the UI.
Adding Test Data
-
Download and unzip the resources for this exercise:
curl https://resources.learn.liferay.com/courses/latest/en/application-development/modeling-data-structures/liferay-g2n9.zip -O
unzip liferay-g2n9.zip
This includes two scripts for creating application and evaluation entries.
-
Navigate to the
curl
folder in theliferay-g2n9
folder:cd liferay-g2n9/curl
-
Run this command to create three entries for the Distributor Application object:
./DistributorApplication_POST_Batch.sh
-
Verify the entries appear in Distributor Applications:
-
Run this command to create three entries for the Application Evaluation object:
./ApplicationEvaluation_POST_Batch.sh
-
Verify the entries appear in Application Evaluations:
Now relate these entries.
Relating Entries
-
Begin editing an Application Evaluation entry.
-
Select a value for the Application to Evaluations field. Available options for the relationship field include all applications you have permission to view.
By default, application entries are identified by their IDs.
-
Open Objects and begin editing the Distributor Application definition.
-
Set the Title Field to Business Name and click Save. This determines the field used to identify object entries in relationship fields.
-
Return to Application Evaluations and begin editing an entry.
-
Select a value for the Application to Evaluations field. Notice that applications are now identified using the business name field.
-
Open Distributor Applications and begin editing an entry.
-
Go to the Evaluation Notes tab.
-
Click Add () and select from existing application evaluations.
The relationship table uses the ID and title field to identify each related evaluation.
-
Update the title field for the Application Evaluation definition to Author.
-
Return to Distributor Applications and notice that the relationship table now uses the ID and Author fields to identify related evaluations.
Conclusion
Congratulations! You have successfully modeled the necessary data structures for Delectable Bonsai’s distributor onboarding flow. Now you can start incorporating the business logic necessary for bringing your application to life, such as workflows, validations, notifications. You’ll do this in the next module.
Module Two: Implementing Business Logic