0% found this document useful (0 votes)
26 views

Relationships

Uploaded by

sudheermuthyala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

Relationships

Uploaded by

sudheermuthyala
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

Relationships:

==============
By using this feature, we can map the association / relation among the Two objects
inside the Organization.

While Mapping the association between the Two objects, we have to follow the below
2 steps.

Step 1: We have to Identify the Parent Object and Child Objects.


Ex: Two Objects "Student (Child)" and "Course(Parent)".

Step 2: Map the Association between the Objects.


i.e. We have to Create an Additional Field inside the Child
Object, which references the Parent Object Id field.

While Creating the Field inside the Child Object, we have to


select any of the Relationship Datatype as below.

1. Lookup Relationship
2. Master-Detail Relationship
3. External Object Lookup Relationship
4. Hierarchical Relationship

Lookup Relationship:
====================
UseCase:
========
Configure the Lookup Relationship between the "Course" object and the
"Student" object. And list out all the observations / functionalities.

Step 1: We have to Identify the Parent Object and Child Object.

Course Object : Parent Object


Student Object : Child Object

Step 2: Map the Lookup Relationship between the Objects.


i.e. We have to Create a Field inside the Student Object with
"Lookup Relationship" Datatype, and can be references to the "Course" object as the
Parent.

Observations:
-------------
1. Lookup Relationship provides One-Many Association between the records.
i.e. A Parent Record can be associated with one or more child records.

2. Lookup Relationship can be applicable on the Objects, where child Object


contains the records inside it.

3. While Creating the Child Record, Selecting the Parent is an optional


field.
i.e. In Lookup Relationship, Child Record may / may not be associated
with the Parent record.

4. In Lookup Relationship, Re-Parenting Option is available by default.


i.e. Once a Child Record has been created by selecting the Parent, then
at any point of time, we can Change the Parent of the child record.

5. In Lookup Relationship, Upon removing the parent record, only parent will
get deleted. Child Record will existed as it is. i.e. Child Record will
not be deleted.
But, in the Child Record, the Lookup Field value will get Cleared out.

6. We can make the Lookup Field required by selecting the "Required Checkbox"
upon Creating / Editing the Lookup field.

7. If the Lookup Field is a Mandatory Field. Then if the user tries to Remove
the Parent Record, Which is associated with a Child Record. Then
Salesforce won't allow to remove the Parent Record.

Sol 1: We need to Delete the Child Records first. And then


remove the
Parent Record from the object.

Sol 2: Re-Parent the related Child records to an another


Parent. And
Delete the Old Parent record from the object.

8. An object can have max. of 40 Lookup Relationship fields.


i.e. A Child Object can be associated with max. of 40 Parent objects.

9. Sharing Settings and Security Settings of the Child Record is purely


independent of the Parent record.

10. Both Parent Record and Child Record contains the "Owner field".

11. Roll-up Summary fields can't be applicable on the Lookup Relationship


objects.

12. We can make a Standard Object as a "Child Object" with Custom Object as
parent with "Lookup Relationship".

Lookup Dialog Configuration:


============================
While Creating the Child Record, when the user click on "Lookup Icon" to
select the Parent record, Then Salesforce will represent the "Lookup Dialog" box.

Lookup Dialog will represent max. of 200 Parent Records in the Tabular
format. We can search the remaining parent records with the help of Search feature.

Note: By default, Lookup Dialog will represent Only the Parent Record Name in
the Table.

We can Customize the Table, to represent the required fields on the Table as
below.

Click on the "Parent Object's Tab" (Ex: HiringManagers)


1. Expand the "Force.com Quick Access Menu".
2. Click on "View Fields" link.
3. Goto the "Search Layouts" section.
4. Click on "Edit" link for the "Lookup Dialog"
5. Select the Required columns to be visible on the Table by
using "Add / Remove" buttons.
6. Arrange the fields in the required order by using "Up / Down"
navigation buttons.
7. Click on "Save" button.

Lookup Filter Configuration:


============================
UseCase:
--------
Configure a Lookup Filter on the Student Object, to represent only those
Course available in the Same Location as the Student inside the Lookup Dialog.
i.e. We have to assign the Students to the Same Location HR People.

Click onthe Required Object's Tab (Ex: Students)


1.Expand the "Force.com Quick Access Menu".
2.Click on "View Fields" link.
3.Goto the "Custom Fields & Relationships" section.
4.Click on "Edit" link for the "Lookup Relationship Field".
5.Goto the "Lookup Filter" Settings Section.
6.Expand the Link "Show Filter Settings".
7.Add the Required Conditions inside the Fields.
Ex:
Student:Location == Course:Location
8. Write the Lookup Window Text inside the TextBox.
9. Select the Checkbox "Enable the Filter".
10. Click on "Save" button.

Master-Detail Relationship:
===========================
Student and Fees

UseCase:
========
Configure the Master-Detail Relationship between the Student and Fees Object
and list out all the Observations.

Step 1: We have to Identify the Parent Object and Child Objects.

Parent Object: Fees Object

Child Object: Student Object

Step 2: Map the Master-Detail Relationship between the Objects.


i.e. We have to Create a Master-Detail Relationship
Datatype field in the Child Object, Which references the Parent Object.

Observations:
1. Master-Detail Relationship provides One-Many Association between the
Objects.(i.e. A Parent Record can be associated with One / More
Child Records)

2. While Mapping the Master-Detail Relationship, if the Child Object


Contains the records. Then Master-Detail Relationship can't ba
applicable.

Sol 1: Remove all the Child Records from the Child Object
Permanently.
And Map the Master-Detail Relationship between the
objects.

Sol 2: We have to map the Lookup Relationship First between the


Objects. And then Make sure each Child Record should
be associated with a Parent Record. Then Convert the association type from Lookup
to Master-Detail Relationship.
3. In Master-Detail Relationship, While Creating the Child Record
selecting the Parent is mandatory. i.e. Master-Detail Field is a
Required field.

4. Re-Parenting option is not available by default. We have to enable


this
option manually by selecting the Checkbox "Allow Re-Parenting"
while creating / editing the field settings.

5. While Removing the Parent Record, all the related child records will
get deleted automatically.

6. Sharing Settings & Security Settings of the Child Record is purely


depends on the Parent Record.

7. Parent Record Contains the "Owner Field". But, Child record doesn't
have the "Owner Field".

8. An object can have max. of 2 Master-Detail relationship fields.

9. Roll-up Summary fields can be applicable on Master-Detail


Relationship
object.

10. In Master-Detail Relationship Standard Object should be always a


Parent Object. It should not be a Child.

Converting Lookup To Master-Detail:


-----------------------------------
Converting Lookup to Master-Detail means, we are Changing the Datatype of the
Relationship field from Lookup to Master-Detail.

Pre-Requisite:
Before Converting the Relationship, we have to make sure each Child
Record in the Child object should be associated with the parent record. Then we
have to convert the Datatype from Lookup to Master-Detail.

Click on the Child Object's Tab (Ex: Students)


1. Expand the "Force.com Quick Access Menu".
2. Click on "View Fields" link.
3. Goto the "Custom Fields & Relationships" section.
4. Click on "Edit" link for the "Lookup Relationship Field".
5. Click on "Change Field Type" button.
6. Select the Datatype as "Master-Detail".
7. Click on "Next" button.
8. Click on "Save" button.

Converting Master-Detail To Lookup:


-----------------------------------
It's a Straight forward option. Where we have to Convert the Relationship
Type from Master-Detail to Lookup directly.

Standard Relationships:
=======================
1. Account and Contact:

Relationship Type : Lookup Relationship


Parent Object : Account
Child Object : Contact

Relationship Field --> Contact:AccountID


Which will store the Parent
Account Id, to which the Contact gets associated.

Note:
While removing the Account Record, all the related Contact
Records will get deleted automatically by default.

This is an additional behavior given by Salesforce based on


the CRM User's Request.

We can break this additional behavior with the help of


"Triggers".

2. Account and Opportunity:

Relationship Type : Lookup Relationship


Parent Object : Account
Child Object : Opportunity

Relationship Field --> Opportunity:AccountID


Which will store the Parent
Account Id, to which the Opportunity gets associated.

Note:
1. Upon deleting the Account Record, if the Account is
associated
with any of the Opportunity Record. Then Salesforce
won't allow you to delete the Account Record from the Object.

2. Between Account and Opportunity, we can Create Roll-up


Summary
Fields also.

3. Account and Case:

Relationship Type : Lookup Relationship


Parent Object : Account
Child Object : Case

Relationship Field --> Case:AccountID


Which will store the Parent
Account Id, to which the Case gets associated.

Note:
While removing the Account Record, if the account is associated
with any Case Record. Then Salesforce won't allows you to remove the Account record
from the object.

You might also like