检索 SugarCRM 员工电子邮件
Retrieve SugarCRM employee emails
我正在为 sugarCRM 编写一些代码,我想通过电子邮件通知员工。我正在使用活动记录模型来获取员工,但找不到他们的电子邮件。
$employees = BeanFactory::getBean('Employees')->get_full_list();
如何通过此界面获取活跃员工的电子邮件?我需要从记录中提取它们并将它们添加到我要发送的电子邮件中。
我也遇到过这种情况,但我想出了以下解决方案。希望对你有效。干杯!!
<?php
$userId=array('2132131312323232','323232323232323'); //array of users id's
foreach($userId as $key => $val) {
$email_query = "select E.email_address from email_addr_bean_rel EB inner join email_addresses E on EB.email_address_id = E.id WHERE EB.bean_id='".$val."' and E.deleted = 0";
// Your implementation
}
?>
参考 sAcH 和这个 the schema documentation,我最终编写了下面的查询。它可能可以清理很多,但它能正常工作,这就是我现在关心的。
它 returns 所有活跃的、未删除的员工的主要电子邮件,有效地为您的活跃用户创建一个电子邮件列表:
select e.email_address
from email_addr_bean_rel eb
inner join email_addresses e
on eb.email_address_id = e.id
where eb.bean_id in
(select id
from users
where deleted = 0 and employee_status = 'Active')
and e.deleted = 0 and eb.primary_address = 1
and eb.deleted = 0 and eb.bean_module = 'Users'
需要注意的重要一点是,用户可以在两个字段中处于活动状态:状态和 employee_status。这检查了后者;请注意,有两个 'status' 字段,而不是一个!
要保存用户的电子邮件地址,请使用:
$sea = new SugarEmailAddress;
$sea->addAddress($bean->email1, true);
$sea->save($newUser->id, "Users");
要检索主电子邮件地址,请使用:
$primary_email=$user->emailAddress->getPrimaryAddress($user);
希望这对您有所帮助...:)
查看更多信息:
SugarCRM Developer
我正在为 sugarCRM 编写一些代码,我想通过电子邮件通知员工。我正在使用活动记录模型来获取员工,但找不到他们的电子邮件。
$employees = BeanFactory::getBean('Employees')->get_full_list();
如何通过此界面获取活跃员工的电子邮件?我需要从记录中提取它们并将它们添加到我要发送的电子邮件中。
我也遇到过这种情况,但我想出了以下解决方案。希望对你有效。干杯!!
<?php
$userId=array('2132131312323232','323232323232323'); //array of users id's
foreach($userId as $key => $val) {
$email_query = "select E.email_address from email_addr_bean_rel EB inner join email_addresses E on EB.email_address_id = E.id WHERE EB.bean_id='".$val."' and E.deleted = 0";
// Your implementation
}
?>
参考 sAcH 和这个 the schema documentation,我最终编写了下面的查询。它可能可以清理很多,但它能正常工作,这就是我现在关心的。
它 returns 所有活跃的、未删除的员工的主要电子邮件,有效地为您的活跃用户创建一个电子邮件列表:
select e.email_address
from email_addr_bean_rel eb
inner join email_addresses e
on eb.email_address_id = e.id
where eb.bean_id in
(select id
from users
where deleted = 0 and employee_status = 'Active')
and e.deleted = 0 and eb.primary_address = 1
and eb.deleted = 0 and eb.bean_module = 'Users'
需要注意的重要一点是,用户可以在两个字段中处于活动状态:状态和 employee_status。这检查了后者;请注意,有两个 'status' 字段,而不是一个!
要保存用户的电子邮件地址,请使用:
$sea = new SugarEmailAddress;
$sea->addAddress($bean->email1, true);
$sea->save($newUser->id, "Users");
要检索主电子邮件地址,请使用:
$primary_email=$user->emailAddress->getPrimaryAddress($user);
希望这对您有所帮助...:)
查看更多信息: SugarCRM Developer