Results 1 to 6 of 6

Thread: Accounts to Contacts

  1. #1
    slamp is offline Junior Member
    Join Date
    Dec 2007
    Posts
    3

    Default Accounts to Contacts

    Hi I have imported successfully from a csv file into Contacts. The issue I have now is that in the Accounts that SugarCRM created, it does not have the address that the Contacts have. How do I copy from Contacts to Accounts? I see a button Copy for Accounts to Contacts but not vice versa. Is there an SQL query I can run to automate this? Please help, we have alot of accounts!

  2. #2
    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: Accounts to Contacts

    Hi, slamp

    Are you sure all contacts related to the same account has the same address information?

    I don´t know how to do this in sql scripts, but I can help you in php.

    Let me know if you need help.

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

  3. #3
    malcolmh's Avatar
    malcolmh is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Aug 2004
    Posts
    1,712

    Default Re: Accounts to Contacts

    Hi,

    Maybe too late, but the way we do it is as follows:

    1. Take the Contact CSV file, copy it then take out all the duplicates Accounts.
    2: Import this new file into Accounts
    3. Import the original file into Contacts

    Hope this helps
    Cheers Malcolm

    Genius4U Limited - Ingenious simple IT solutions for you / Genial einfache IT Lösungen für Sie
    http://www.genius4u.com or http://www.genius4u.de

  4. #4
    slamp is offline Junior Member
    Join Date
    Dec 2007
    Posts
    3

    Default Re: Accounts to Contacts

    thanks for all the replies. i was able to create a php script that did what we wanted. if anyone is interested here is the code.



    Code:
    <?php
    $dbhost = 'localhost';
    $dbuser = 'root';
    $dbpass = 'password';
    $dbname = 'sugarcrm_database';
    
    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
    
    mysql_select_db($dbname);
    
    $query  = "select a.id, c.primary_address_street, c.primary_address_city, c.primary_address_state, c.primary_address_postalcode from accounts as a, contacts as c, accounts_contacts as ac where a.id = ac.account_id and c.id = ac.contact_id";
    $result = mysql_query($query);
    
    while($row = mysql_fetch_array($result, MYSQL_ASSOC))
    {
            if (isset($row['primary_address_street'])) {
                    $update = "update accounts set billing_address_street = '$row[primary_address_street]',
                                    billing_address_city = '$row[primary_address_city]',
                                    billing_address_state = '$row[primary_address_state]',
                                    billing_address_postalcode = '$row[primary_address_postalcode]'
                                    where id = '$row[id]'";
                    mysql_query($update) or die('Error, query failed');
            }
            else {
                    echo "row is empty\n";
            }
    }
    
    mysql_close($conn);
    ?>

  5. #5
    aram is offline Sugar Community Member
    Join Date
    Aug 2004
    Posts
    52

    Default Re: Accounts to Contacts

    When we update info in an Account, such as address it does not also get updated in the related Contacts.
    I realize this may not be something that would make sense all the time
    .
    However, is there a method to give a choice to update Contact info with Account address updates
    (like a button "Update all Related Contact info too?"

    We find that most all of our Contacts (over 60,000) have the sane address as the Account they are related to, but we have to manually update the address in each Contact when updating the Account.

    Aram

  6. #6
    sqpc is offline Member
    Join Date
    Nov 2007
    Posts
    8

    Default Re: Accounts to Contacts

    Aram, that would save time. If you come up with solution please post it.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Linking Contacts to Accounts During Import
    By andybesy in forum Help
    Replies: 12
    Last Post: 2012-05-21, 12:18 PM
  2. Accounts, Contacts and B2C implementations
    By organi in forum General Discussion
    Replies: 46
    Last Post: 2010-05-23, 07:04 PM
  3. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  4. Replies: 0
    Last Post: 2006-07-26, 08:42 PM
  5. Contacts vs Accounts
    By jcrutchfield@nmxs.com in forum Help
    Replies: 2
    Last Post: 2006-07-06, 09:19 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
  •