Monday, September 16, 2013

One to One relationship in Salesforce

Well, Salesforce offers  one to many relationship  and recently Many to Many relationship has 
also been possible using the concept of a Junction object...

But, is there a One to One relationship in Salesforce. Well, it is not available out of the Box.
But is definitely achievable using simple workflow rules...

Scenario:

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.....

No comments:

Post a Comment