Professional Documents
Culture Documents
By Gayatri Sharma
Relationships:
• Relationships associate objects with other objects.
• For example, a relationship can link a custom object to standard
object in a related list, such as linking a custom object called Bugs to
cases to track product defects associated with customer cases.
• For example, the account has a lookup on himself, called Parent
Account.
Sobject Relationship Types
• Master Detail
• Look up
• Self
• Hierarchical
What is “Master-Detail Relationship”?
• Master Detail relationship is the Parent child relationship.
• In which Master represents Parent and detail represents Child.
• If Parent is deleted then Child also gets deleted.
• Rollup summary fields can only be created on Master records which will
calculate the SUM, AVG, MIN of the Child records.
• Up to 2 allowed to object.
• Parent field on child is required.
• Access to parent determines access to children.
• Deleting parent automatically deletes child.
• A child of one master detail relationship cannot be the parent of another.
• Lookup field on page layout is required.
Master Detail
• Q: Can we create master detail relationship on existing records?
• A: "You cannot create a new Master-Detail relationship on
an existing custom object if records already exist. You must
first create a Lookup relationship, populate the lookup field with data
in all records, and then change the relationship type to Master-Detail
• Q: How many master detail relationships can you have on an object in
Salesforce?
• A: There is only 2 Master Detail Relationship allowed per object and
it can have upto three custom detail levels. Each object is allowed to
have one or two masters, or up to 8 details.
What is a roll up summary field in Salesforce?
• Roll up summary field can only be defined on the master object.
While your formula fields calculate values using fields within a single
record, roll-up summary fields calculate values from a set of related
records, such as those in a related list.
What can a cross object formula reference?
• Cross-object formulas are formulas that span two
related objects and reference merge fields on those objects. Cross-
object formulas can reference merge fields from a master
(“parent”) object if an object is on the detail side of a master-detail
relationship. Cross-object formulas also work with lookup
relationships.
What is a “Lookup Relationship”?
• On a standard or custom object, a lookup relationship creates
a field that allows users to click a lookup icon and select another
record from a popup window. On an external object,
the lookup relationship field references 18-character SalesforceIDs
that are stored in an external data source.
What is a “Lookup Relationship”?
• Up to 25 allowed for object.
• Parent is not a required field.
• No impact on a security and access.
• No impact on deletion.
• Can be multiple layers deep.
• Lookup field is not required.
If you have any of these 4 requirements, then
go with master detail (otherwise lookup):
• When the parent record is deleted all the child records attached
needs to be deleted.
• All the users who can access a specific parent record will also has
access to all the related child records (parent has private OWD setting
and has sharing rules on top of it)
• wants to create rollup summary fields on parent
• activities tagged to child records has to be shown on parent account
too
Junction object
• the sole purpose of a junction object is to simply relate two objects, so it
often makes sense to give the junction object a name that indicates the
association or relationship it creates. For example, if you wanted to use a
junction object to create a many-to-many relationship between bugs and
cases, you could name the junction object BugCaseAssociation.
• Let's look at a typical scenario. There are open positions for a Project
Manager and a Sr. Developer. The Project Manager position is only posted
on Monster.com, but the Sr. Developer position is more difficult to fill, so
it's posted on both Monster.com and Naukri. Every time a position is
posted, a job posting record tracks the post. As you can see in the following
diagram, one position can be posted many times, and both positions can
be posted to the same employment website.
Entity Relationship Diagram for the Position,
Job Posting, and Employment Website Objects
new list<RollUpSummaryUtility.fieldDefinition> {
'TotalFee__c')
};
RollUpSummaryUtility.ObjectDefination objDef =
new RollUpSummaryUtility.ObjectDefination('Application__c','StudentId__c','Student__c','',null);