About the Shared Embedded Terminology

In the Shared Embedded model, there are four roles that can be defined:

About the Embedded Entity Role

This is the entity that is embedded in one or more container entities via an embedded link field. From a designer perspective, creating an embedded entity is the same as creating an entity, except you need to add three fields to support the sharing functionality:

  • OwnerEntity (nvarchar(100)): This field identifies the entity name for the record that "owns" a particular embedded record. For example, for a company's address, that Addresses record has Companies as its OwnerEntity.
  • OwnerRecordID (int or bigint): This field identifies the record in the OwnerEntity that "owns" a particular embedded record. For a company's address, this is the ID of the particular Companies record that owns an Addresses record.
  • Locked (bit): This field indicates whether or not an embedded record may be updated. When set to 1, the embedded record has a static relationship with one or more container records.  

    Shared Embedded Fields in Addresses Entity

About the Shared Embedded Owner Role

Each embedded record that is shared has an owner. This is the record from which a user initially creates the shared record. For example, an address that is shared among a company and the people at that company is owned by the company. For that particular Addresses record, the OwnerEntity would be "Companies" and the -OwnerRecordID would be the ID of the top-level company's record. The embedded link field for the Owner entity defines the sharing and update logic for all of the other container records that share the same embedded record.

The embedded link field for the owner entity has the following settings, as illustrated in the figure below, which shows the AddressID field in the Companies entity:

  • Linked Entity: The name of the embedded entity.
  • Linked Entity Field: Typically, the ID field in the embedded entity.
  • Link Type: Embedded
  • Mode: Dynamic. This setting adds a Dynamic Sharing tab to the Fields record.
  • Dynamic Flowdown Proc: This link box specifies the stored procedure which defines the logic for updating the dynamic non-owner shared links specified in the Dynamic Sharing sub-type -listing.
    • A developer needs to write a stored procedure and add it as a Database Objects record. This stored procedure should define how updates made to the embedded record at the owner level are propagated to other dynamic non-owner links. See the stored procedures that are linked to the Companies entity's AddressID field and the Organizations entity's AddressID field for examples.
    • This stored procedure does not establish the sharing relationship between an owner and non-owner container records, it only maintains the relationship and performs updates as needed. To perform the initial flow-down (for example, to associate a company's address when you add a company to a Persons form), you typically specify this logic in an entity plug-in object for the non-owner entity.

       Embedded Link Owner Field

  • Dynamic Sharing Relationships Sub-Type: This sub-type control stores the list of entities and their embedded links that can share an embedded record with this owner entity as a non-owner. Each sub-type record stores the Related Entity name, the Related Entity Field (this is the embedded link in the Related Entity that links to the shared embedded object), and a Dynamic Flowdown Filter (which you can use to filter the set of records to which this shared embedded object relationship applies). For the Companies entity's AddressID field, one type of non-owner records is updated dynamically (the specific update logic is stored in the Dynamic Flowdown stored procedure):
    • Persons/AddressID: This corresponds to the business address for Persons who are associated with the company.

       Dynamic Sharing Relationships Record


About the Dynamic Shared Embedded Non-Owner Role

Like the Dynamic Shared Embedded Non-Owner link, this type of link also identifies a non-owner entity for a shared embedded link. However, once linked, a static non-owner locks the embedded record to prevent future updates. If a user subsequently modifies the embedded record data at the owner level, Aptify automatically creates a clone of the original record, links it to the owner, updates the dynamic non-owner links to use the new record, and then modifies the record as necessary. The static record retains its link to the original, unchanged embedded record.

In Aptify, an Order's Bill To and Ship To addresses use static embedded links to a Person's address. At the time an order is created, the Person's address (which is typically owned by the Person's corresponding Company) automatically flows down to the Orders record via logic in the Orders entity object. However, if a Company's address subsequently changes (which would change the Person's address), it would not be appropriate to carry this change over to the Order's Bill To and Ship To addresses. An address change would affect future orders, but it should not affect those that occurred in the past.

The embedded link field for a static non-owner entity has the following settings, as illustrated in the figure below, which shows the ShipToAddressID field in the Orders entity:

  • Linked Entity: The name of the embedded entity.
  • Linked Entity Field: Typically, the ID field in the embedded entity.
  • Link Type: Embedded
  • Mode: Static 

     Static Shared Embedded Link
  • Non-Owner Entity Object: A developer specifies the initial flow-down logic to link the non-owner to the shared embedded record in an entity plug-in object for the non-owner entity. See Adding Plug-Ins to an Entity for details.


About the Static Shared Embedded Non-Owner Role

Like the Dynamic Shared Embedded Non-Owner link, this type of link also identifies a non-owner entity for a shared embedded link. However, once linked, a static non-owner locks the embedded record to prevent future updates. If a user subsequently modifies the embedded record data at the owner level, Aptify automatically creates a clone of the original record, links it to the owner, updates the dynamic non-owner links to use the new record, and then modifies the record as necessary. The static record retains its link to the original, unchanged embedded record.

In Aptify, an Order's Bill To and Ship To addresses use static embedded links to a Person's address. At the time an order is created, the Person's address (which is typically owned by the Person's corresponding Company) automatically flows down to the Orders record via logic in the Orders entity object. However, if a Company's address subsequently changes (which would change the Person's address), it would not be appropriate to carry this change over to the Order's Bill To and Ship To addresses. An address change would affect future orders, but it should not affect those that occurred in the past.

The embedded link field for a static non-owner entity has the following settings, as illustrated in the figure below, which shows the ShipToAddressID field in the Orders entity:

  • Linked Entity: The name of the embedded entity.
  • Linked Entity Field: Typically, the ID field in the embedded entity.
  • Link Type: Embedded
  • Mode: Static 

     Static Shared Embedded Link
  • Non-Owner Entity Object: A developer specifies the initial flow-down logic to link the non-owner to the shared embedded record in an entity plug-in object for the non-owner entity. See Adding Plug-Ins to an Entity for details.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.