CAllCrmLead::ProcessCompanyDeletion

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. CAllCrmLead
  4. ProcessCompanyDeletion
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/classes/general/crm_lead.php
  • Класс: \CAllCrmLead
  • Вызов: CAllCrmLead::ProcessCompanyDeletion
static function ProcessCompanyDeletion($companyID)
{
	$dbResult = self::GetListEx(
		array(),
		array('=COMPANY_ID' => $companyID, 'CHECK_PERMISSIONS' => 'N'),
		false,
		false,
		array('ID')
	);

	$companyIdentifier = null;
	if ($companyID > 0)
	{
		$companyIdentifier = new Crm\ItemIdentifier(\CCrmOwnerType::Company, (int)$companyID);
	}

	$entity = new CCrmLead(false);
	while($fields = $dbResult->Fetch())
	{
		$fields['COMPANY_ID'] = 0;
		$entity->Update(
			$fields['ID'],
			$fields,
			true,
			true,
			[
				'EXCLUDE_FROM_RELATION_REGISTRATION' => [
					$companyIdentifier,
				],
			],
		);
	}
}

Добавить комментарий