• Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/recycling/dealcontroller.php
  • Класс: Bitrix\Crm\Recycling\DealController
  • Вызов: DealController::prepareFields
protected function prepareFields(array $fields): array
{
	$categoryId = isset($fields['CATEGORY_ID']) ? (int)$fields['CATEGORY_ID'] : 0;
	if ($categoryId > 0 && !Crm\Category\DealCategory::isEnabled($categoryId))
	{
		$categoryId = 0;
	}
	$fields['CATEGORY_ID'] = $categoryId;

	if (
		isset($fields['STAGE_ID'])
		&& !\CCrmDeal::IsStageExists($fields['STAGE_ID'], $categoryId)
	)
	{
		// if old stage does not exist, STAGE_ID should be empty to be defined automatically
		unset($fields['STAGE_ID']);
	}

	return $fields;
}