Create a Related Object Relationship Between Service Requests and Opportunities

A related object subtab lists records from one object that's related to another object. Using Application Composer, you can create one-to-many relationships between two objects within the same application.

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, your users might want to associate an opportunity with a list of service requests that have been logged for that opportunity. To create a one-to-many relationship, you specify a source object and target object. A reference relationship lets you add a subtab to the source object's details page, showing a list of all the target object records that are associated with a single source object record.

Create a One-to-Many Relationship

To expose a list of service requests associated with a specific opportunity as a subtab on the opportunity's details page, you must first create a one-to-many relationship between both the service request and opportunity objects.

Here are the steps to create a relationship between a service request and an opportunity.

  1. Sign in as a sales administrator or as a setup user.

  2. Activate a sandbox.

  3. Navigate to Application Composer, in the Configuration category.

  4. Select Relationships in the Common Setup pane.

  5. On the Relationships page, click the Create icon.

  6. In the Source Object field, select Opportunity.

  7. In the Target Object field, select Service Request.

  8. Enter the relationship name, display name, and description.

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

  9. In the Cardinality field, select 1:M.

  10. Click Save and Close.

Add Related Object Subtab

You now want to add the target object Service Request as a subtab to the source object's Opportunity detail page.

Here are the steps to add the related object subtab to the opportunity.

  1. In the navigation tree, expand Standard Objects, expand Opportunity, and click Pages.

  2. Ensure that the Application Pages tab is selected.

  3. In the Details Page Layouts region, duplicate the standard layout by highlighting the standard layout and clicking the Duplicate icon.

  4. Type a new layout name and click Save and Edit.

    The Details Layout page appears.

  5. On the Edit Layout page, select the plus icon in the subtabs region.

  6. On the Create Subtab page, select the Related object option.

  7. Click Next.

  8. Specify the values for the fields as follows:

    Field Label

    Select or Enter

    Description

    Data Object

    Service Request

    The object that this subtab is based on. This subtab displays a list of service requests that are related to an opportunity.

    Display Label

    Service Request Name

    Name of the subtab.

    Drill Down Column

    Service Request Name

    Your users can click this column to drill down to view more details about a service request record.

    Display Icon

    As applicable

    This icon appears on the application page as the subtab icon.

    Selected Fields

    As applicable

    The fields that you want to appear on the subtab.

  9. Save the Service Request Name subtab.

    You have created a subtab to display service requests on a subtab which appears on the Opportunity details page.

  10. Click Done and ensure that the layout status for your user-defined layout is Active.

  11. Test the changes: Navigate to Sales > Opportunities as a user with access to the opportunity pages, for example, as a salesperson. Edit an opportunity and ensure you can see the Service Request subtab in the Edit Opportunity page.

  12. Publish the sandbox.