One-to-Many Relationships

Using Application Composer, you can create one-to-many relationships between two objects within the same application, where one object's primary identifier is stored in another object's table.

A relationship must exist before you can expose the "many" objects on a subtab that's displayed on the "one" object's details page or tree. For example, an account can have multiple service requests associated to it. To expose a list of service requests associated with a specific account as a subtab on the account's details page, you must first create a one-to-many relationship between the account and service request objects. Create these relationships implicitly by creating a child object or by creating a dynamic choice list. Or, create relationships explicitly on the Create Relationship page.

Once you create a one-to-many relationship, you can't delete it.

Parent Child Relationships

Parent child relationships are implicitly created when a custom object is created as a child of a top-level object.

When a child object is created, it's created specifically in the context of its parent. A child object doesn't have its own work area, and the child object is deleted if the parent object is deleted.

View parent child relationships in the object tree, where child objects appear as sub-nodes beneath their parent objects. If a parent child relationship exists, then the child object is listed on the parent's Object Overview page in the Child Objects region. A top-level object can have many child objects. A child object can have only one parent object.

Relationships that are implicitly created from parent child relationships are also displayed on the Relationships page. The relationship name is automatically generated for you.

Dynamic Choice List Relationships

Choice list relationships are implicitly created between two objects when you create a dynamic choice list field.

A dynamic choice list is a field that contains a list of values which are populated from the actual data of another object. For example, you might want to expose on a page a dynamic choice list which lets users specify the HR representative of a given department. The HR Representative choice list is a field that you're adding to the department object, but the list of values is populated by actual employees from the employee object.

When you select an object and create a dynamic choice list field based on a related object, you're implicitly creating a one-to-many foreign key relationship where the current object is the "many" object and the related object is the "one" object. This implicit creation of a relationship lets you later add a related object subtab for the "many" object on the "one" object's details page. You can view these implicitly created choice list relationships on the Relationships page.

View dynamic choice list relationships on an object's Object Overview page. If such a relationship exists, then the related object is listed on the object's Object Overview page in the Related Objects region.

These objects are related objects, not parent child objects. Related objects aren't deleted if the current object is deleted.

Relationships that are implicitly created from dynamic choice list relationships are also displayed on the Relationships page. The relationship name is automatically generated for you.

Note:

Generally, the dynamic choice list that you create results in the implicit creation of a choice list relationship. The exception is if you're in a global single instance environment and you create a dynamic choice list between an Oracle CX Sales and Fusion Service object and a common object: resource, customer contact profile, account, address. In such cases, relationships aren't implicitly created.

Creating Reference Relationships

Create a foreign key-based, one-to-many relationship between two top-level objects explicitly using the Create Relationship page. This type of relationship is called a reference relationship.

To explicitly create a relationship between two top-level objects within the same application:

  1. Select Relationships in the Common Setup pane.

  2. On the Relationships page, click the New icon.

  3. Select the source object and target object.

    A child object can't be the source object or target object.

    The Note common component isn't available for selection as either a source object or target object.

    Once you create a relationship, you can no longer edit the source and target objects.

    This relationship adds a field to the target object to store the foreign key details. If the source object is ever deleted, the target object records remain.

  4. Enter the relationship name and description.

    Once you create a relationship, you can no longer edit the relationship name.

  5. Optionally add the target object in a subtab to the source object's detail page.

  6. Optionally specify data filter criteria for both the source and target objects.

    The filter criteria that you specify here controls which records are available for association at runtime with a record from the other object in this relationship.

    Read: "Configuring a Search and Select Dialog for Custom Objects".

Note:

You can create multiple relationships between the same source and target objects. For example, create both a Primary Contact and Secondary Contact relationship between the contact and opportunity objects.

Groovy Script Syntax

Once you have created a one-to-many relationship between objects, a foreign key field is created on the child object or on the "many" object. Use the following API names to access those foreign keys in your scripts.

Relationship Type

Foreign Key API Name

Pattern Used

Parent/child relationship

If the parent object name is ParentObj_c, then the foreign key API name (added to the child object) is ParentObj_Id_c.

<Name of the parent object>_Id_c

Dynamic choice list relationship

If the dynamic choice list field name is DynChoice1_c, then the foreign key API name is DynChoice1_Id_c.

<Name of the dynamic choice list field>_Id_c

Reference relationship (one-to-many)

If the source object name is SourceObj_c, the target object name is TargetObj_c, and the relationship name is relation_Mto1, then the foreign key API name (added to the target object) is SourceObj_Id_relation_Mto1.

<Name of the source object>_Id_<Name of the relationship>