#165 ✓resolved
Wai-Sun Chia

One contact can be in MANY companies

Reported by Wai-Sun Chia | January 31st, 2010 @ 09:35 PM | in 0.9.10 "Alekhine"

Recently, I met up with a CRM propsect in an accounting firm, and he was asking me how to relate this person who is a director is at least 5 companies. I told him that he'd need to key it in 5 times FOR NOW.

So is there a way to implement a one-to-many relationship for contact and account?

Comments and changes to this ticket

  • Gordon McAllister

    Gordon McAllister February 23rd, 2010 @ 01:04 AM

    Just my 2 cents.

    This becomes a bit thorny when you now have 5 addresses and contact numbers for the same contact. People traditionally think of a contact as having one address i.e. its not very common but does occur. Representing these relationship can be tricky - you don't want to overcomplicate the UI to handle these rare instances but you do want to have the ability to handle such occurances.


  • mattgow

    mattgow August 4th, 2010 @ 12:05 AM

    • Assigned user cleared.
    • Tag set to affiliation
    • Milestone order changed from “0” to “0”

    The concept of an "affiliation" might be useful here. For a good example see Batchbook (get a demo account and play with it. A little bit of text description is available at http://support.batchbook.com/faqs/affiliations/what-is-an-affiliation )

    Any given contact still belongs to only one company. However, contacts and organisations can have any number of affiliations. These are essentially named links.

    This approach is not restricted to a Company/Employee relationship. You could define relationships between companies and companies, individuals and companies or individuals and individuals. E.g.

    child / parent
    competitor / competitor
    contractor / client
    friend / friend
    partner / partner
    sibling / sibling
    spouse / spouse
    vendor / customer

    In Batchbook these are just displayed in a sidebar whenever you view a contact or company. However, in a list of contacts, the "company" field will be populated with the company for that individual with no regard for relationships (so the simple case remains the core path and remains simple)

  • mattgow

    mattgow August 4th, 2010 @ 03:10 AM

    • Assigned user set to “Mike Dvorkin”
  • Nathan B

    Nathan B August 11th, 2010 @ 02:43 AM

    • Tag changed from affiliation to many accounts, affiliation, bug, contact, relationship

    I am currently working on a plugin for merging contacts, and have discovered that this is in fact a bug in the code.

    I was working out how to merge 2 contacts from different accounts into a contact that is a member of both accounts. I discovered that this is not meant to be possible, although it can still be done in the UI.

    To replicate:

    1) Start FFCRM in development mode, after running rake crm:demo:load
    2) Visit the 'Accounts' tab.
    3) Click the first account.
    4) Under the 'Contacts' heading, choose 'Select Contact'
    5) Type a random letter and add the first contact that shows up. Remember the name for later.
    6) Go back to the accounts page, and click the second account.
    7) Choose 'Select Contact' again, and add the same contact from step 5.
    8) Now visit the 'Contacts' tab.
    9) In the 'Search contacts' box, type in the contacts name from step 5.
    10) Click the 'edit' link on the contacts row.
    11) In the 'edit' frame, change the selected 'Account' option to a different account.
    12) Click 'save'.
    13) Notice that the 'account' of the user is NOT the account that you selected.
    14) Edit the user again, choose another Account, and click save.
    15) Notice again the 'account' of the user has not been assigned properly.

    The bug stems from the :has_one account relationship through AccountContact defined in the Contact model. Accounts can have many contacts, but there is no check in place to make sure that the same contact is not being added to many accounts.

    There are two solutions to this problem:

    a) Open up the Account -> Contact relationship and let a contact have many accounts.
    - This will require a small change to the contact edit form, introducing multiple select-lists for more than one account.

    b) Lock the relationship down and filter the AJAX search during step 5 (remove any contacts that already have one account).

    My personal preference would be [a], and I understand that you have probably already considered this. But for now, the result of a contact merge will have to remove the relationship from one of the contact accounts.

    Nathan B

  • Mike Dvorkin

    Mike Dvorkin August 11th, 2010 @ 10:30 AM

    Nathan, thanks for detailed bug report, this is very helpful. It clearly sounds like a bug and I'm going to write a test case and fix it. I'm leaning towards (b) although I think there is no need to filter contacts -- just to make sure the selected contact gets associated with one account properly.

  • Mike Dvorkin

    Mike Dvorkin August 17th, 2010 @ 09:40 PM

    • State changed from “new” to “resolved”

    (from [65bb9c1bf281442863c71c4ebbe1e2ef22c94452]) Properly set the account value when attaching a contact to the account [#165 state:resolved] http://github.com/michaeldv/fat_free_crm/commit/65bb9c1bf281442863c...

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Ruby on Rails CRM platform for Web 2.0 and beyond

Referenced by