Results 1 to 5 of 5

Thread: Access contact list from logic hook in Opportunity module

  1. #1
    seth.ellingson is offline Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Default Access contact list from logic hook in Opportunity module

    Using a logic hook in the Opportunities module, I want to access the contact list that is associated with an opportunity. In Opportunity.php, i see the get_contacts() method that returns an array. However, I cannot seem to print out any of the info. Here is the code that I am trying:

    Code:
    $contacts = $bean->get_contacts();
    			
    foreach($contacts as $contact) {
          $GLOBALS['log']->debug("Contact_list: ".$contact->email1);
    }
    I must be handling the array wrong, but I don't know if get_contacts() is returning an array of objects or a multi-dimensional array. Any help would be appreciated.

    I am using SugarPro 6.3.1 and PHP 5.2.6 on Linux with Apache2.

    Thanks

  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: Access contact list from logic hook in Opportunity module

    It returns an array of Contact objects.

    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.

  3. #3
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: Access contact list from logic hook in Opportunity module

    Whether you still with problems you could try:
    $bean->load_relationship('contacts'); //please confirm relationship name
    $contacts = $bean->contcats->get();
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

  4. #4
    seth.ellingson is offline Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Default Re: Access contact list from logic hook in Opportunity module

    Thank you both. What ended up working for me was the following:
    Code:
    $bean->load_relationship('contacts');
    $contacts = $bean->contacts->get();
    			
    foreach($contacts as $contact) {
    	$con = new Contact();
    	$con->retrieve($contact);
    	$GLOBALS['log']->debug("Contact_ftp2: ".$con->email1);
    }

  5. #5
    seth.ellingson is offline Junior Member
    Join Date
    Oct 2011
    Posts
    3

    Default Re: Access contact list from logic hook in Opportunity module

    hmm, there is one problem with this way of retrieving the contact info.... I cannot access the opportunity_role... Does anyone know how to access the opportunity_role of a contact within an opportunity? Thanks in advance!

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 2011-10-12, 01:08 PM
  2. Access to Custom Fields in After Save Logic Hook
    By chad.hutchins in forum Developer Help
    Replies: 4
    Last Post: 2010-05-11, 03:42 PM
  3. Replies: 3
    Last Post: 2009-08-15, 03:00 AM
  4. Access records from logic hook
    By ishaan in forum Developer Help
    Replies: 2
    Last Post: 2009-06-11, 06:48 AM
  5. loading contact lists via logic hook?
    By michamamo2 in forum Developer Help
    Replies: 8
    Last Post: 2008-11-05, 08:39 AM

Tags for this Thread

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
  •