Emails does not appear after BeanFactory::getBean("Contacts",$contact_bean_id);

I’m trying to retrieve all information about a record but using Beanfactory the Email field does not return even though it’s in the record when I view it in the list view.

Is there a way for me to get the emails of a contact or lead using a builtin function?

I know how to do it for Users but not for Leads or Contacts.

Thank you

Version 7.7.9
Sugar Version 6.5.24 (Build 509)

Hi,
You can use the following code to get all the record data with email addresses

require_once ‘modules/Leads/Lead.php’;
$lead = new Lead();
$lead->retrieve(‘your-record-id’);
echo ‘

’;
print_r($lead);

require_once ‘modules/Contacts/Contact.php’;
$contact = new Contact();
$contact->retrieve(‘your-record-id’);
echo ‘

’;
print_r($contact);

so for first email address you can use

$lead->email1
$contact->email1

and for second email address you can use email2, for third one email3 and so on.

Thanks

Try a field called “email1”

Emails is a special field, because it’s actually relating to a different module. Each person can have more then one Email.

That field “email1” is a handy shortcut to the primary email.

1 Like