Loading

Create a hierarchy (parent/child relationship) within the same object

Udgivelsesdato: Oct 13, 2022
Beskrivelse

Create a hierarchy (parent/child relationship) within the same object

Løsning

Aside from Account Hierarchy, this is currently not a functionality provided by Salesforce CRM. This can be accomplish this by creating a Custom Object that would do a double look up on itself.
To create a parent-child relationship within the same object follow the instructions below:

Create a New custom object:

In Classic:  Setup | App Setup | Create | Objects | New Custom Object.
In Lightning:  Gear Icon | Setup | Object Manager | Create | Custom Objects
  1. Name it "Sub", i.e. SubOpportunity
  2. Select Auto Number for the Data Type
  3. Do not select any of the "Optional Features" nor any of the "Object Creation" options.
  4. Save


Create a Custom Relationship within the new Object. This relationship establishes the Parent Object

  1. Data Type = Lookup Relationship
  2. Related to = select the Object you want to create the hierarchy in
  3. Field Label = Parent, i.e. ParentOpportunity
  4.  Related List Label = Sub
  5. Save


Create a second Custom Relationship within the new object. This relationship selects the Sub Object.

  1. Data Type = Lookup Relationship
  2. Related to = select the object you want to create the hierarchy in (same object as above)
  3. Field Label = Sub, i.e. SubOpportunity
  4. Related List Label = Parent
  5. Save


Modify Related List to view correct labels but navigating to:

In Classic:  Setup | App Setup | Customize | Object | Page Layouts | Edit | Related List Section | Select 'Sub' (the previously created object
In Lightning:  Gear Icon | Setup | Object Manager | Select 'Sub' (the previously created custom object) | Page Layouts | Edit | Related List Section
  1. Edit Related List Properties
  2. Move Sub field from Available Fields to Selected Fields
  3. Click "OK".
  4. Save Page Layout.
  5. Select Parent | Edit Related List Properties
  6. Move Parent field from Available Fields to Selected Fields
  7. Click "OK"
  8. Save Page Layout.


Now users can create a new Sub- record that can contain a reference to another one similar to a hierarchical set up, on a parent-child fashion.

For additional information related to object relationships please review the article below:

https://help.salesforce.com/articleView?id=overview_of_custom_object_relationships.htm&type=5

See Also: Set Up Account Hierarchy in Lightning Experience
Vidensartikelnummer

000385441

 
Indlæser
Salesforce Help | Article