Results 1 to 7 of 7

Thread: Update Contact Owner with Account Owner

  1. #1
    fbnewtz is offline Sugar Community Member
    Join Date
    Jun 2006
    Posts
    31

    Default Update Contact Owner with Account Owner

    Is there an easy way to update all of the contact record owners with the same owner as the account associated with those contacts?

    I can't imagine that I am the first person who wants to make this happen. We use permissions to only allow our sales agents to see their own accounts. We had a custom portal developed for our agents that would allow them to get their appointments each day, but now I want to move this functionality into Sugar. Our appointment setters already complain about all of the steps required when they set appointments already. Adding an additional step would be enough to start a mutiny around here.

    Any help or even a pointer into something that is similar functionality wise that could allow me to write some custom functionality would be great.

    Thanks,

    Fred
    http://www.top10php.com/PHP Coder

  2. #2
    mikesolomon is offline Sugar Community Member
    Join Date
    Feb 2008
    Location
    UK
    Posts
    1,467

    Default Re: Update Contact Owner with Account Owner

    Quote Originally Posted by fbnewtz View Post
    Is there an easy way to update all of the contact record owners with the same owner as the account associated with those contacts?

    I can't imagine that I am the first person who wants to make this happen. We use permissions to only allow our sales agents to see their own accounts. We had a custom portal developed for our agents that would allow them to get their appointments each day, but now I want to move this functionality into Sugar. Our appointment setters already complain about all of the steps required when they set appointments already. Adding an additional step would be enough to start a mutiny around here.

    Any help or even a pointer into something that is similar functionality wise that could allow me to write some custom functionality would be great.

    Thanks,

    Fred
    to update the existing contacts to have the same owner as the account could be done by sql

    then create a before save logic hook on contacts to get the assigned_user_id from the account

    you could also do a before_save on accounts to update contacts
    Mike Solomon
    Development Manager
    Ivy Ltd
    www.ivy.ltd.uk]www.ivy.ltd.uk

    php version 5.2.6
    MySql 5.1.59

  3. #3
    fbnewtz is offline Sugar Community Member
    Join Date
    Jun 2006
    Posts
    31

    Default Re: Update Contact Owner with Account Owner

    Sounds easy enough. Now I just need to make it happen!


    Thanks,

    Fred
    http://www.top10php.com/PHP Coder

  4. #4
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Update Contact Owner with Account Owner

    This SQL should do it for MySQL:
    Code:
    update contacts
    inner join accounts_contacts on contacts.id = accounts_contacts.contact_id and accounts_contacts.deleted = 0
    inner join accounts on accounts_contacts.account_id = accounts.id and accounts.deleted = 0
    set contacts.assigned_user_id = accounts.assigned_user_id
    where contacts.deleted = 0
    If a contact is related to multiple accounts though it'll just grab one of them

  5. #5
    fbnewtz is offline Sugar Community Member
    Join Date
    Jun 2006
    Posts
    31

    Default Re: Update Contact Owner with Account Owner

    Quote Originally Posted by eggsurplus View Post
    This SQL should do it for MySQL:
    Code:
    update contacts
    inner join accounts_contacts on contacts.id = accounts_contacts.contact_id and accounts_contacts.deleted = 0
    inner join accounts on accounts_contacts.account_id = accounts.id and accounts.deleted = 0
    set contacts.assigned_user_id = accounts.assigned_user_id
    where contacts.deleted = 0
    If a contact is related to multiple accounts though it'll just grab one of them
    Wow. Thanks a million! It would have taken me hours to come up with that query.

    Thanks,

    Fred
    http://www.top10php.com/PHP Coder

  6. #6
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Update Contact Owner with Account Owner

    No problem. Glad to have helped!

  7. #7
    mrjeremiahross is offline Junior Member
    Join Date
    Dec 2008
    Posts
    1

    Default Re: Update Contact Owner with Account Owner

    I apologize, but you will have to talk to me like I am 5.

    What I really need to do is as follows:

    (Ideally without changing contact owners) I would like contacts to be viewable by

    1) Admin (done in permissions)

    2) Owner (done in permissions)

    3) User who is the owner of the account which is linked to that particular contact (The only option I can find is to manually update the contacts with new owners)

    Any suggestions?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Assigning Co-owner for Account - Multiple Assigned User
    By webnetin in forum Developer Help
    Replies: 15
    Last Post: 2009-12-11, 12:04 AM
  2. Viewing reports for OWNER ONLY
    By gkeyes in forum Help
    Replies: 2
    Last Post: 2008-05-14, 06:16 PM
  3. Business owner needs help
    By ttax in forum Help
    Replies: 1
    Last Post: 2008-02-03, 06:23 PM
  4. Replies: 2
    Last Post: 2007-11-13, 02:09 PM
  5. Replies: 2
    Last Post: 2007-02-07, 07:38 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
  •