I have a before save logic hook in the Leads area where I check if a lead or contact exists by email address before creating a new lead. I am calling: $ret = $sea->getBeansByEmailAddress($email); to do this.
The odd thing is this function returns contact beans fine, but not leads.If an email address exists and linked to a lead, it does not return the bean.
I ran a debug through to include/SugarEmailAddress/SugarEmailAddress.php where the function generates a query. In my example this query is generated when I call $ret = $sea->getBeansByEmailAddress($email); in my logic hook:
SELECT * FROM email_addr_bean_rel eabl JOIN email_addresses ea ON (ea.id = eabl.email_address_id)
WHERE ea.email_address_caps = 'JOHNNY.APPLESEED@PIONEER.COM' and eabl.deleted=0
When I execute this query against the database it returns a result where bean_module is Leads and bean_id is populated. However, the function is returning an empty array rather than the lead bean.
Has anyone seen something similar before? I am on 7.7.x Enterprise. Any thoughts on this issue are appreciated.