• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/lib/scrum/service/taskservice.php
  • Класс: BitrixTasksScrumServiceTaskService
  • Вызов: TaskService::createTask
public function createTask(array $taskFields): int
{
	try
	{
		$taskItemObject = CTaskItem::add($taskFields, $this->executiveUserId);

		$taskId = $taskItemObject->getId();

		if (!$taskId)
		{
			if ($exception = $this->application->getException())
			{
				$this->errorCollection->setError(
					new Error(
						$exception->getString(),
						self::ERROR_COULD_NOT_ADD_TASK
					)
				);
			}
			else
			{
				$this->errorCollection->setError(
					new Error(
						'Error creating task',
						self::ERROR_COULD_NOT_ADD_TASK
					)
				);
			}
		}

		return $taskId;
	}
	catch (Exception $exception)
	{
		$message = $exception->getMessage().$exception->getTraceAsString();

		$this->errorCollection->setError(
			new Error(
				$message,
				self::ERROR_COULD_NOT_ADD_TASK
			)
		);

		return 0;
	}
}