Define Quotation Relationships
Key Lesson: Paired many-to-one and one-to-many relationships let each child reference its parent while each parent exposes its collection of related records.
Complete the extended purchasing model with two parent-child relationship pairs:
- Each
Quotationlinks to onePurchaseRequestthroughpurchaseRequest, while onePurchaseRequestexposes multipleQuotationrecords throughquotations. - Each
QuotationItemlinks to oneQuotationthroughquotation, while oneQuotationexposes multipleQuotationItemrecords throughitems.
For each pair, configure the child-to-parent many-to-one relationship first. Then configure the parent-to-child one-to-many relationship and select the first relationship as its inverse.
Note
The existing documentation verifies the relationship names below but does not establish exact ID property names for these two new child-to-parent links. Leave each generated or default ID property name unchanged rather than entering an unsupported name.
1. Link each quotation to its purchase request
Section titled “1. Link each quotation to its purchase request”- Open the
QuotationEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | purchaseRequest |
| 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) |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The purchaseRequest relationship exposes the parent purchase request from each quotation.
2. Expose quotations on each purchase request
Section titled “2. Expose quotations on each purchase request”- Open the
PurchaseRequestEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | quotations |
| TARGET ENTITY | Purchasing.Quotation |
| 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 | purchaseRequest |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The quotations relationship exposes the related records as a collection, such as request.quotations or screen.request.quotations.
3. Link each quotation item to its quotation
Section titled “3. Link each quotation item to its quotation”- Open the
QuotationItemEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | quotation |
| TARGET ENTITY | Purchasing.Quotation |
| 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) |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The quotation relationship exposes the parent quotation from each quotation item.
4. Expose items on each quotation
Section titled “4. Expose items on each quotation”- Open the
QuotationEntity editor. - Go to ENTITY RELATIONSHIPS and select +.
- Configure the relationship as follows:
| Setting | Value |
|---|---|
| NAME | items |
| TARGET ENTITY | Purchasing.QuotationItem |
| 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 | quotation |
- Leave the remaining relationship settings at their default values.
-
Save and close the editor.
The items relationship exposes the related quotation items as a collection.
Tip
If the INVERSE RELATIONSHIP dropdown is empty, save the many-to-one relationship, refresh the Entity editor, and check the dropdown again.
Verify the extended data model
Section titled “Verify the extended data model”Verify only the quotation model introduced in this stage: the two new Entities, both directions of the two new relationships, the currency-precision requirement to apply later, and the resulting application build.
1. Verify the Quotation Entity
Section titled “1. Verify the Quotation Entity”- In Design, open the
QuotationEntity. - Confirm that Id type is
number. - Confirm that
vendorhas typestringand no default expression. - Confirm that
currencyhas typeThis.Currencyand a default expression ofThis.Currency.Usd.
The Quotation Entity contains the vendor and currency properties used for each vendor quotation entry.
If a property, type, or default expression differs, compare the Entity with Create Quotation Entities and correct the configuration before continuing.
2. Verify the QuotationItem Entity
Section titled “2. Verify the QuotationItem Entity”- Open the
QuotationItemEntity. - Confirm that Id type is
number. - Verify these properties:
description:string.quantity:number.unitPrice:number.
The QuotationItem Entity contains the description, quantity, and unitPrice properties required for a quoted line item.
If a property or type differs, compare the Entity with Create Quotation Entities. Keep unitPrice; it stores the supplier’s quoted price and is part of this model stage.
3. Verify the purchase request and quotation relationship
Section titled “3. Verify the purchase request and quotation relationship”- In the
QuotationEntity, open ENTITY RELATIONSHIPS. - Confirm that
purchaseRequesttargetsPurchasing.PurchaseRequestand uses many-to-one. - In the
PurchaseRequestEntity, open ENTITY RELATIONSHIPS. - Confirm that
quotationstargetsPurchasing.Quotation, uses one-to-many, and selectspurchaseRequestas its inverse relationship.
Each quotation links to one corresponding purchase request, and each purchase request exposes its related quotations through the quotations collection.
If the relationship direction, target, or inverse differs, return to Define Quotation Relationships. If the inverse relationship is unavailable, save the many-to-one relationship first, refresh the Entity editor, and check again.
4. Verify the quotation and quotation item relationship
Section titled “4. Verify the quotation and quotation item relationship”- In the
QuotationItemEntity, open ENTITY RELATIONSHIPS. - Confirm that
quotationtargetsPurchasing.Quotationand uses many-to-one. - In the
QuotationEntity, open ENTITY RELATIONSHIPS. - Confirm that
itemstargetsPurchasing.QuotationItem, uses one-to-many, and selectsquotationas its inverse relationship.
Each quotation item links to one corresponding quotation, and each quotation exposes its related items through the items collection.
If the relationship direction, target, or inverse differs, compare both Entities with Define Quotation Relationships and correct the mismatched side.
5. Confirm the currency precision requirement
Section titled “5. Confirm the currency precision requirement”The Entity model defines QuotationItem.unitPrice as a number. Set its persisted precision to 2 later in Extend Storage and Access for Quotation Data, when the quotation Entities are added to the existing Server Data Store, before building the Request Quotations Screen.
6. Confirm the application builds
Section titled “6. 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 extended data model in place.
If the application name turns red, select the red exclamation mark and correct the reported Entity or relationship error. Do not continue until the application builds successfully.
7. Confirm the extended data model is ready
Section titled “7. Confirm the extended data model is ready”Use this checklist to confirm that this stage is complete.
Next, extend storage and access for quotation data before building the Request Quotations Screen.