- Модуль: crm
- Путь к файлу: ~/bitrix/modules/crm/lib/entitymanagefacility.php
- Класс: Bitrix\Crm\EntityManageFacility
- Вызов: EntityManageFacility::registerContact
public function registerContact(array &$fields, $updateSearch = true, $options = array())
{
$this->registeredId = null;
$this->registeredTypeId = \CCrmOwnerType::Contact;
$this->isBpRun = false;
if ($this->canAddContact())
{
// use entity configuration setting when create
if (!isset($fields['OPENED']) || empty($fields['OPENED']))
{
$fields['OPENED'] = Settings\ContactSettings::getCurrent()->getOpenedFlag() ? 'Y' : 'N';
}
$contact = new \CCrmContact(false);
$this->registeredId = $contact->add($fields, $updateSearch, $options);
$this->registeredEntities->addIdentificator(
$this->registeredTypeId,
$this->registeredId,
true
);
if (!$this->registeredId)
{
$this->errors[] = $contact->LAST_ERROR;
}
else
{
$this->traceEntity($this->registeredTypeId, $this->registeredId);
}
}
elseif ($this->canUpdate())
{
$this->updateClientFields($fields, true, $updateSearch, $options);
}
if ($this->isAutomationRun)
{
$this->runAutomation();
}
return !empty($this->registeredId);
}