• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/order/contactcompanyentity.php
  • Класс: Bitrix\Crm\Order\ContactCompanyEntity
  • Вызов: ContactCompanyEntity::checkValueBeforeSet
public function checkValueBeforeSet($name, $value)
{
	if (
		$name === 'IS_PRIMARY'
		&& $value === 'Y'
	)
	{
		/** @var ContactCompanyCollection $collection */
		$collection = $this->getCollection();
		if ($collection)
		{
			if ($collection->isPrimaryItemExists(static::getEntityType()))
			{
				throw new Main\SystemException('Primary entity has already existed');
			}
		}
	}

	return parent::checkValueBeforeSet($name, $value);
}