Results 1 to 8 of 8

Thread: Many-to-many relation question

  1. #1
    tvandesande is offline Member
    Join Date
    Jun 2008
    Posts
    16

    Default Many-to-many relation question

    Hi all,

    i'm implementing a SugarCRM in my company, but i've found a touch challenge for me to figure out. I hope i'll get some assistance from You guys.
    So... in my CRM Contacts would act as basically Contacts - so people. Then Accounts would act as Organizations that people (Contacts) belong to. And here's a challenge, i need to be able to assign a person to multiple organizations. So a contact would be associated with one or more Accounts.

    would this be possible?
    can anyone help please?

    greetings
    piotr

  2. #2
    tvandesande is offline Member
    Join Date
    Jun 2008
    Posts
    16

    Default Re: Many-to-many relation question

    No one knows?

  3. #3
    bchardon is offline Senior Member
    Join Date
    Jun 2008
    Location
    Lausanne, CH
    Posts
    21

    Default Re: Many-to-many relation question

    Hello,

    With a little customization work, this is possible.
    Currently, the link between contacts and accounts seems to be many-to-one, but by editing the vardefs (several posts on this subjects in the forum and the wiki), you can turn it into a many-to-many relationship.
    Baptiste Chardon

  4. #4
    tvandesande is offline Member
    Join Date
    Jun 2008
    Posts
    16

    Default Re: Many-to-many relation question

    @bchardon thanks for reply, i really appreciate this! i'll take a look into this.

    anyone else has some info on implementing many-to-many relation?

  5. #5
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Many-to-many relation question

    Hi, tvandesande

    The relationship between Accounts and Contacts are many-to-many.

    Sugar automatically gets the first Accounts linked to a Contact and defines it as the Account Name for that Contact.
    But it does not mean the relationship is one-to-many.
    You can link as Accounts you wish to the same contact.
    To avoid get confusing you could remove from editviewdefs.php and detailviewdefs.php the account_name.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  6. #6
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Many-to-many relation question

    Hi,
    maybe you could be interested in adding an accounts subpanel inside a contact, so you can see which accounts a contact is related to.
    What do you think the cookie monster eats ?

  7. #7
    tvandesande is offline Member
    Join Date
    Jun 2008
    Posts
    16

    Default Re: Many-to-many relation question

    yes i've just realised that there is many to many relation there but it doesn't quite work as i'd like it to.

    basically if i have a contact, and want to assign it to lets say 3 accounts, then three copies of this contact are created one for each account. and i'd like to have just one.

  8. #8
    DragonflyMaster is offline Sugar Community Member
    Join Date
    Dec 2007
    Location
    Rimini, Italy
    Posts
    1,421

    Default Re: Many-to-many relation question

    Quote Originally Posted by tvandesande
    yes i've just realised that there is many to many relation there but it doesn't quite work as i'd like it to.

    basically if i have a contact, and want to assign it to lets say 3 accounts, then three copies of this contact are created one for each account. and i'd like to have just one.
    What happens is not actually a new contact creation for each new related account, but just a new line addition to contact's listview page for each account.
    My workaround consists in a little hack:
    open <sugar-root>/modules/Contacts/vardefs.php
    and delete/comment the following code:
    PHP Code:
    'account_name' =>
            array (
                
    'name' => 'account_name',
                
    'rname' => 'name',
                
    'id_name' => 'account_id',
                
    'vname' => 'LBL_ACCOUNT_NAME',
                
    'join_name'=>'accounts',
                
    'type' => 'relate',
                
    'link' => 'accounts',
                
    'table' => 'accounts',
                
    'isnull' => 'true',
                
    'module' => 'Accounts',
                
    'dbType' => 'varchar',
                
    'len' => '255',
                
    'source' => 'non-db',
                
    'unified_search' => true,
            ),
        
    'account_id' =>
            array (
                
    'name' => 'account_id',
                
    'rname' => 'id',
                
    'id_name' => 'account_id',
                
    'vname' => 'LBL_ACCOUNT_ID',
                
    'type' => 'relate',
                
    'table' => 'accounts',
                
    'isnull' => 'true',
                
    'module' => 'Accounts',
                
    'dbType' => 'id',
                
    'reportable'=>false,
                
    'source' => 'non-db',
                
    'massupdate' => false,
                
    'duplicate_merge'=> 'disabled',
                
    'hideacl'=>true,

            ), 
    Then clear template data cache and rebuild relationships.
    What do you think the cookie monster eats ?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2009-06-10, 08:01 PM
  2. filter popup data by relation
    By waverider in forum Developer Help
    Replies: 6
    Last Post: 2008-09-18, 02:23 PM
  3. Hebrew / general right-to-left language question
    By amitr in forum General Discussion
    Replies: 1
    Last Post: 2008-09-12, 05:40 PM
  4. Question About New Email Module
    By rfenn in forum Help
    Replies: 0
    Last Post: 2007-12-19, 08:30 PM
  5. Question regarding Sugar Public License
    By netstruXure in forum General Discussion
    Replies: 1
    Last Post: 2005-03-23, 11:11 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •