Types of relationships that Salesforce provide
In this article we'll be using Master-detail relationship to implement one-to-one relationship.
Scenario
Note: The relationship here is show by a line joining the two objects. The line diagram is quite intuitive. The multiple forks the end suggests the child objects.
As of now we have created a relationship where a department can have multiple managers, but that's not what we are looking for; hold on
Solution
To make a this relationship one-to-one we will be using rollup summary concept.
- Master-detail relationship
- Lookup
In this article we'll be using Master-detail relationship to implement one-to-one relationship.
Scenario
- Every department has only one manager
- One manager can manage only one Department
Note: The relationship here is show by a line joining the two objects. The line diagram is quite intuitive. The multiple forks the end suggests the child objects.
As of now we have created a relationship where a department can have multiple managers, but that's not what we are looking for; hold on
Solution
To make a this relationship one-to-one we will be using rollup summary concept.
- Create a rollup summary field managerCount (count) in departments, this will be auto populated depending upon the number of managers associated with that particular department.
- Create a validation rule in department object on managerCount field. Throw an error "department can be managed by only one manager"when the managerCount is greater that 1.