Answer the question
In order to leave comments, you need to log in
How to check for the existence of leads with the same Email. Bitrix24. Boxed version?
When creating a lead, you need to check for the existence of leads with the same Email. How to do this if the array returned by the CCrmLead::GetList (CCrmLead::GetListEx) methods does not contain an email or fm field?
Answer the question
In order to leave comments, you need to log in
Let's do it a little differently:
Examine the following code and the crm.duplicate.findbycomm rest method. See /home/bitrix/www/bitrix/modules/crm/classes/general/restservice.php
use \Bitrix\Main;
use \Bitrix\Crm;
/* @var string Email, который будем искать */
$sEmail = '[email protected]';
/* @var array ID лидов, которые попадаются под условия */
$arLeadIds = [];
if ( Main\Loader::IncludeModule('crm') )
{
// Формируем критерий, подсовываем Email
$criterion = new Crm\Integrity\DuplicateCommunicationCriterion( Crm\CommunicationType::EMAIL_NAME, $sEmail);
// Выполняем поиск первых 20 клиентов
$duplicate = $criterion->find( \CCrmOwnerType::Lead, 20);
// Если найдены entity проитерируем их
$entities = $duplicate->getEntities();
if ( !empty($entities) )
{
foreach($entities as $entity)
{
$arLeadIds[] = $entity->getEntityID();
}
}
}
// А тут будут ID сделок
var_dump($arLeadIds);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question