• Модуль: rpa
  • Путь к файлу: ~/bitrix/modules/rpa/lib/command/update.php
  • Класс: BitrixRpaCommandUpdate
  • Вызов: Update::checkTasks
public function checkTasks(): Result
{
	$result = new Result();

	// do not check tasks for update on the same stage.
	if(!$this->item->isChanged('STAGE_ID'))
	{
		return $result;
	}

	if (!BizprocAutomationFactory::canUseAutomation())
	{
		return $result;
	}

	$taskManager = Driver::getInstance()->getTaskManager();
	if(!$taskManager)
	{
		return $result;
	}
	$stageChanged = $taskManager->onItemStageUpdate($this->item, $this->item->getStageId(), $this->userId);

	if ($stageChanged)
	{
		$this->terminate();
		return $result;
	}

	$participants = $taskManager->getItemTaskParticipants($this->item);

	// check tasks for actual stage. $this->item->remindActualStageId();
	//if current user has tasks for this item
	if(in_array($this->userId, $participants, true))
	{
		$result->addError(new Error(Loc::getMessage('RPA_COMMAND_ITEM_USER_HAS_TASKS'), static::ERROR_CODE_ITEM_USER_HAS_TASKS));
	}
	//if any user has tasks for this item
	elseif($participants)
	{
		$result->addError(new Error(Loc::getMessage('RPA_COMMAND_ITEM_TASKS_NOT_COMPLETED'), static::ERROR_CODE_ITEM_TASKS_NOT_COMPLETED));
	}

	return $result;
}