One to One relationship in Salesforce

11:28 PM

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


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


  1. Hey Sumit, I came to know aboout this from Marc ( trainer)... So, the full credit goes to him :-)

  2. Why not just use a lookup relationship for a one to one?

  3. Using a look up relationship does not restrict it for a one to one, basically it means a one to many.. accounts and contacts for ex... By using the above you can restrict the relationship to one to one using the same lookup

  4. In a very unique implementation of SF, I need to have one-to-many relationship between contact and accounts. For e.g. one contact belongs to more than one account. Any ideas ?

  5. Hi,

    Could you be more specific about workflow rule criteria.I did not understand what is the criteria.

  6. Hello,

    For the workflow Rule you will have to do the following..

    Create a Workflow with the option "Only when a record is created"

    Add a Workflow field update and update the UNIQUE field that you created with the "Account" lookup field..

    Hope it helps.. Let me know if you are able to do this

  7. Hi,

    I still cannot!. Let me walk you through the steps i did.

    1) created a field called onetoone on contact of type Text.

    2) Created a workflow rule on contact with following criteria:

    a) Only when record is created
    b) Under Rule criteria, i selected when "Formula evaluates to true"
    c) onetoone__c=Accountid.
    d) did not understand what to do in workflow action.

    Let me know, if i am missing anything.

    Thanks in advance.

  8. Here you go with the detailed steps..

    1) You have already created a field of type Text called onetoone, so let's skip this step.

    2) Create a Workflow rule

    a) Select the object Contact
    b) Everytime a record is created or edited.
    c) Rule criteria is, AccountId "does not equal" <--Leave this text box blank -->

    d) In Workflow action, create a field update.
    e) Select the field "onetone"
    f) In the formula editor, select the field AccountId
    g) click DONE and activate your worflow rule.

    Hope this helps!!

  9. check this...

  10. I have stumbled on this site and would like to post a question unrelated to above thread... can I use the post a comment or is there somewhere else i should go? e-mail is

  11. from paul...
    I volunteered to put Non Profit sf in for a local charity... I opted for the 1to1 account model. I have just finished the config and all had been working fine until today when I tried to create a new contact and I got following err msg...
    Error: Invalid Data. Review all error messages below to correct your data. Apex trigger npe5.Affiliations caused an unexpected exception, contact your administrator: npe5.Affiliations: execution of AfterInsert caused by: System.UnexpectedException: No such column 'RecordTypeId' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.: (npe5)

    Before I start to traul through stuff Iwondered if this msg points to an obvious error to a more experienced eye?

    Thanks in advance to anyone who can help me... my e-mail address is

  12. Hi Paul.. Sorry, i did not get time to reply to your previous question you sent me some time back..

    The error message that you received looks straightforward... I just got a few more questions..

    What is the type of Edition you use?
    Do you have recordtypes enabled for account?

    Thanks, Edwin

  13. Hello Paul.. Just found out that the error you are facing is a known bug in the Winter11 release..

    Check This

  14. Hi Edwin,
    I was reading through the this post trying to find an answer to a similiar problem. Perhaps you can help.

    I want to create a one to one relationship lookup between to account records. They are person accounts. Specifically, I want to link spouse records. I don't want a related list, I just need a spouse record to poplulate in the lookup, then also create a recipricol record on the other spouse automatically. Do you know how to do something like this using lookups?

  15. Workflow rules are only available when you have Enterprise edition of SF. Any solution for the users of the Pro Edition???

  16. Why do we want to create a one to one relationship between Accounts and Contacts? For me One to many from Account to Contact looks very natural. In the example are we trying to restrict one contact to one Account?

  17. Chacha, Workflow rule only available only in Enterprise, unlimited and developer editions. The only way is to upgrade to Enterprise.

  18. Hi,This is Kirti Rathod. I want to create one to one relation on custom it necessary to have look up relation between two objects ?.If it is necessary than it will going to show on child object as a field as a lookup relation .n i don't want to show it so i need to use page layout to hide that field?