• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/automation/factory.php
  • Класс: Bitrix\Crm\Automation\Factory
  • Вызов: Factory::runLeadFreeScenario
static function runLeadFreeScenario($entityId)
{
	$result = new Result();

	$converter = Converter\Factory::create(\CCrmOwnerType::Lead, $entityId);
	$config = LeadSettings::getCurrent()->getFreeModeConverterConfig();

	if (!$config['completeActivities'])
	{
		$converter->enableActivityCompletion(false);
	}

	$itemOptions = ['categoryId' => $config['dealCategoryId'] ?: 0];
	$items = $config['items'] ? $config['items'] : [\CCrmOwnerType::Deal, \CCrmOwnerType::Contact];

	foreach ($items as $itemTypeId)
	{
		$converter->setTargetItem($itemTypeId, $itemOptions);
	}

	$result->setConversionResult($converter->execute());

	return $result;
}