Results 1 to 3 of 3

Thread: Contacts Accounts Search Relationship

  1. #1
    Jax.Smith is offline Member
    Join Date
    Jul 2009
    Posts
    15

    Exclamation Contacts Accounts Search Relationship

    Hi there,

    I am trying to replicate the search feature that is available in the SugarCrm. My sugar is currently loaded with demo data. The image below shows that when I search for a contact, it will return all accounts related to this contact.



    If you could please tell me what files or codes I need to edit.

    Thank You,
    Jax

  2. #2
    datasponge is offline Sugar Community Member
    Join Date
    Mar 2008
    Location
    San Jose, CA, USA
    Posts
    553

    Default Re: Contacts Accounts Search Relationship

    Hi Jax,

    Do you mean the php files or the database files?

    In the underlying sugarcrm database there are three relevant tables:
    accounts
    contacts
    accounts_contacts

    accounts and contacts each have a field named `id`. accounts_contacts has fields `id`, `account_id` and `contact_id`.

    You would find the accounts for a contact with a query something like:

    SELECT * from (accounts INNER JOIN accounts_contacts ON accounts.id = accounts_contacts.account_id) INNER JOIN contacts ON accounts_contacts.contact_id = contacts.id WHERE contacts.last_name = 'Smith';

    This would give you a recordset with all the accounts and contacts fields for which the last name in contacts is 'Smith'

    Phil

  3. #3
    Jax.Smith is offline Member
    Join Date
    Jul 2009
    Posts
    15

    Default Re: Contacts Accounts Search Relationship

    Hi Phil,

    Thanks for replying. I am more into php files because it can create the table when i rebuild. The code you gave me where exactly do I put it?

    Thanks again,
    Jax
    Last edited by Jax.Smith; 2009-08-05 at 04:36 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Contacts and their relationship to Accounts?
    By messageimpact in forum Help
    Replies: 5
    Last Post: 2009-11-24, 10:37 AM
  2. Contacts Accounts Search Relationship
    By Jax.Smith in forum Developer Help
    Replies: 0
    Last Post: 2009-08-04, 05:35 PM
  3. Relationship between Contacts and Accounts
    By chrislynch8 in forum Help
    Replies: 1
    Last Post: 2009-07-16, 03:18 PM
  4. Changing relationship between Accounts and Contacts?
    By ljbutler in forum Developer Help
    Replies: 1
    Last Post: 2008-03-06, 12:52 PM
  5. Contacts <--> Accounts relationship data
    By bokonon in forum Developer Help
    Replies: 3
    Last Post: 2006-12-18, 10:23 AM

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
  •