function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Aniket SupeAniket Supe 

how many ways we can achieve one-to -one relationship in salesforce.

Deepthi BDeepthi B
Hello Aniket,

Let's consider the scenario that we would like to establish a One to One relationship between Accounts and Contacts..
Step 1:
Create a custom field on the Contact object. Make the field unique. This field would be used to hold the ID of the associated Account.

Step 2:
Create a Workflow rule on Contact. Update the custom field with the value of the associated Account ID.

Done!! you have established a one to one relationship between Account and Contacts...
When you try to add a second contact to the Account, the "unique" constraint would be violated and an error would be thrown.....
You can also check the link for other way to creating one to one relationship :
 http://one-to-one-salesforce.blogspot.in/ 

Hope this helps you!
Regards,
Deepthi

 
Sumit Kumar Singh 9Sumit Kumar Singh 9
The possible ways are - 
1) Validation rule
2) Trigger


Thanks, 
Sumit Kuamr Singh
salesforce mesalesforce me
hi check this once....

https://books.google.co.in/books?id=-HrKBAAAQBAJ&pg=PT62&lpg=PT62&dq=what+is++one-to+-one+relationship+in+salesforce&source=bl&ots=FxaJniOZ1t&sig=d8_qEkcBBOpx8OmbEoWEA6MPjQU&hl=en&sa=X&ved=0ahUKEwjy5tWk9MvKAhVNB44KHYMhDScQ6AEIGzAA#v=onepage&q=what%20is%20%20one-to%20-one%20relationship%20in%20salesforce&f=false
salesforce mesalesforce me
hi check this once....



Types of relationships that Salesforce provide
Master-detail relationship
LookupI assume that you are familiar with the difference between the two relations.
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 DepartmentGo to schema builder and create two objects Manager and Departments. Then create a Master-Detail relationship between the Department and manager.
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.




User-added image






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.