Define the Purchase Request Relationship
Key Lesson: A paired many-to-one and one-to-many relationship lets each item reference its parent request while the request exposes its collection of items.
Connect the two purchase request Entities:
- Each
PurchaseRequestItemlinks to its parentPurchaseRequestthrough itsrequestproperty. - Each
PurchaseRequestlinks to its relatedPurchaseRequestItemobjects through itsitemsproperty.
Configure the many-to-one relationship first. Then configure the one-to-many relationship and select the first relationship as its inverse.
1. Link each item to its purchase request
Section titled “1. Link each item to its purchase request”- Open the
PurchaseRequestItemEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | request |
| TARGET ENTITY | Purchasing.PurchaseRequest |
| RELATION TYPE | many-to-one: Many instances of this Entity have a relationship to a single instance of the target Entity (e.g. Address → Person) |
| ID PROPERTY NAME | Leave empty. Lowgile automatically uses requestId. |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The request relationship exposes the parent record as item.request. Its requestId property stores the data-model/database identity used to link the child item to its corresponding purchase request.
2. Expose the items on each purchase request
Section titled “2. Expose the items on each purchase request”- Open the
PurchaseRequestEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | items |
| TARGET ENTITY | Purchasing.PurchaseRequestItem |
| RELATION TYPE | one-to-many: One instance of this Entity has a relationship to multiple instances of the target Entity (e.g. Person → Address) |
| INVERSE RELATIONSHIP | request |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The items relationship exposes the related records as a collection, such as request.items or screen.request.items.
Tip
If the INVERSE RELATIONSHIP dropdown is empty, press F5 to refresh the Entity editor, then check the dropdown again.
Verify the minimum data model
Section titled “Verify the minimum data model”Before building the first Screens, verify that the Purchasing application contains the four minimum data-model objects and that the purchase request relationship is configured in both directions.
1. Verify the purchase request relationship
Section titled “1. Verify the purchase request relationship”- In the
PurchaseRequestItemEntity, open ENTITY RELATIONSHIPS. - Confirm that
requesttargetsPurchasing.PurchaseRequestand uses many-to-one. Leave ID property name empty so Lowgile automatically usesrequestId. - In the
PurchaseRequestEntity, open ENTITY RELATIONSHIPS. - Confirm that
itemstargetsPurchasing.PurchaseRequestItem, uses one-to-many, and selectsrequestas its inverse relationship.
Each purchase request item links to one corresponding purchase request, and each purchase request exposes its related items as the items collection.
If the relationship direction, target, or inverse does not match, return to Define the Purchase Request Relationship. If the inverse relationship is unavailable, save the many-to-one relationship first, refresh the Entity editor, and check again.
2. Confirm the application builds
Section titled “2. Confirm the application builds”- Return to the main Studio editor.
- In Design, locate the Purchasing application.
- Wait for the application name to turn green.
The Purchasing application builds successfully with the minimum data model in place.
If the application name turns red, select the red exclamation mark and correct the reported data-model error. Do not start building Screens until the application builds successfully.
The minimum data model is ready. The next stage uses these objects to build the first purchase request Screens.