• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/checklist/internals/checklisttree.php
  • Класс: BitrixTasksCheckListInternalsCheckListTree
  • Вызов: CheckListTree::getClosestParentId
static function getClosestParentId($id)
{
	$id = (int)$id;

	/** @var DataManager $dataController */
	$dataController = static::getDataController();
	$parentColumnName = static::getParentNodeColumnName();
	$childColumnName = static::getNodeColumnName();
	$levelColumnName = static::getLevelColumnName();

	$item = $dataController::getList([
		'select' => [$parentColumnName],
		'filter' => [
			$childColumnName => $id,
			$levelColumnName => 1
		],
	])->fetch();

	if (!$item)
	{
		return $id;
	}

	return $item[$parentColumnName];
}