• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/field.php
  • Класс: Bitrix\Crm\Field
  • Вызов: Field::isValueUnique
protected function isValueUnique($value, int $id = null): bool
{
	if($this->isValueEmpty($value))
	{
		return false;
	}
	if(!is_scalar($value))
	{
		return true;
	}
	$tableClassName = $this->settings['tableClassName'] ?? null;
	if(!$tableClassName || !is_a($tableClassName, DataManager::class, true))
	{
		return true;
	}

	$filter = [
		'=' . $this->getName() => $value,
	];
	if($id > 0)
	{
		$filter['!=' . Item::FIELD_NAME_ID] = $id;
	}

	return ((int) $tableClassName::getCount($filter) === 0);
}