Skip to content

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 PurchaseRequestItem links to its parent PurchaseRequest through its request property.
  • Each PurchaseRequest links to its related PurchaseRequestItem objects through its items property.

Configure the many-to-one relationship first. Then configure the one-to-many relationship and select the first relationship as its inverse.

  1. Open the PurchaseRequestItem Entity editor.
  2. Go to ENTITY RELATIONSHIPS and select +.
  3. Configure the relationship as follows:
SettingValue
NAMErequest
TARGET ENTITYPurchasing.PurchaseRequest
RELATION TYPEmany-to-one: Many instances of this Entity have a relationship to a single instance of the target Entity (e.g. Address → Person)
ID PROPERTY NAMELeave empty. Lowgile automatically uses requestId.
  1. Leave the remaining relationship settings at their default values.
  2. 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”
  1. Open the PurchaseRequest Entity editor.
  2. Go to ENTITY RELATIONSHIPS and select +.
  3. Configure the relationship as follows:
SettingValue
NAMEitems
TARGET ENTITYPurchasing.PurchaseRequestItem
RELATION TYPEone-to-many: One instance of this Entity has a relationship to multiple instances of the target Entity (e.g. Person → Address)
INVERSE RELATIONSHIPrequest
  1. Leave the remaining relationship settings at their default values.
  2. 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.

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”
  1. In the PurchaseRequestItem Entity, open ENTITY RELATIONSHIPS.
  2. Confirm that request targets Purchasing.PurchaseRequest and uses many-to-one. Leave ID property name empty so Lowgile automatically uses requestId.
  3. In the PurchaseRequest Entity, open ENTITY RELATIONSHIPS.
  4. Confirm that items targets Purchasing.PurchaseRequestItem, uses one-to-many, and selects request as its inverse relationship.
Expected result:

Each purchase request item links to one corresponding purchase request, and each purchase request exposes its related items as the items collection.

If this does not happen:

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.

  1. Return to the main Studio editor.
  2. In Design, locate the Purchasing application.
  3. Wait for the application name to turn green.
Expected result:

The Purchasing application builds successfully with the minimum data model in place.

If this does not happen:

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.