This section describes how Aptify uses Shared Embedded Objects to manage addresses across Companies, Persons, and Orders. In this implementation, the Embedded Entity is Addresses, the Shared Embedded Owner is Companies, the Dynamic Shared Embedded Non-Owner is Persons, and the Static Shared Embedded Non-Owner is Orders.
The following steps outline Aptify's addressing implementation:
- A user creates a new top-level company (Companies ID 1) and specifies a Street Address.
- A new record is added to the Companies entity.
- Aptify creates a new Addresses record for the specified address (Addresses ID 1). The Companies record is the Addresses record's owner in the shared embedded model. The Companies entity's AddressID field has the settings described in "About the Shared Embedded Owner " on page 976 and Role and shown in Figure B.9the figure below. The Addresses record has the following embedded field values:
- OwnerEntity: Companies
- OwnerRecordID: The ID of the new Companies record.
- Locked: 0
- The following figure illustrates the relationship between these records.
- A user creates a new Persons record and specifies Companies ID 1 as the Company -(Persons ID 1). The company's Street Address automatically flows down to the person's Business Address.
- The logic contained in the Persons entity's entity object automatically -associates the Persons record's AddressID with the same AddressID from the specified Companies record (Addresses ID 1).
- Addresses ID 1's Owner remains Companies ID 1. Persons ID 1 is a dynamic non-owner to Addresses ID 1.
- The Persons entity's AddressID field has the settings described in "About the Dynamic Shared Embedded Non-Owner " on page 978 and Role and shown in Figure B.11.in the figure below.
- A user creates a second new Persons record and specifies Companies ID 1 as the Company (Persons ID 2). The company's Street Address automatically flows down to the person's Business Address. But in this case, the user specifies a different Business Address for the person.
- Modifying the address on the Persons record breaks the shared embedded link between the Companies record and the Persons record.
- Aptify creates a new Addresses record for the Person's specified address (Addresses ID 2) and specifies the Persons record as the Addresses record's owner.
- A user modifies the Street Address for Companies ID 1.
- The changes the user specified are saved in Addresses ID 1.
- These changes are automatically applied to Persons ID 1, since this person shares a link to the same Addresses record.
- No changes are made to Persons ID 2's address since it linked to a different Addresses record.
- A user creates and saves an order for Persons ID 1 (Orders ID 1).
- The logic contained in the Orders entity's entity plug-in object automatically - associates the Orders record's ShipToAddressID and BillToAddressID with the same AddressID from the specified Persons record (which happens to be owned by the associated Companies record, Addresses ID 1).
- The Orders entity's ShipToAddressID and BillToAddressID fields have the settings described in "About the Static Shared Embedded Non-Owner " on page 979 and Role and shown in Figure B.12the figure below.
- Since the Orders entity is a Static link, Addresses ID 1 becomes Locked to prevent any further modification to that Addresses record. Note that Companies ID 1 and Persons ID 1 remain linked to Addresses ID 1
.
- Companies ID 1 moves and its Street Address changes. A user opens the Companies ID 1 record and modifies the Street Address.
- Since Addresses ID 1 has been locked by Orders ID 1, Aptify creates a new Addresses record to store the company's updated Street Address and links - Companies ID 1 and Persons ID 1 to this new address (Addresses ID 3).
- The Owner Record for Addresses ID 1 changes from Companies ID 1 to -Companies ID -1, which reflects the fact that Companies ID 1 is no longer the owner of this record. An ID of -1 indicates a blank value.
- Orders ID 1 remains linked to Addresses ID 1.
- Addresses ID 1's owner entity remains Companies, even though Companies ID 1 is no longer linked to it.
- Persons ID 2 remains linked to Addresses ID 2, since it is was unlinked from the company's address at an earlier point.