Task::updateStatus

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Task
  4. updateStatus
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/provider/tasks/task.php
  • Класс: Bitrix\Crm\Activity\Provider\Tasks\Task
  • Вызов: Task::updateStatus
public function updateStatus(int $taskId, string $desiredStatus): void
{
	$activity = $this->find($taskId, true);
	if (!$activity)
	{
		// nothing to update
		return;
	}

	$settings = $activity->getSettings();
	if (!is_array($settings) || !isset($settings['ACTIVITY_STATUS']))
	{
		// no status
		return;
	}

	$currStatus = $settings['ACTIVITY_STATUS'];
	$taskActivityStatus = new TaskActivityStatus();
	if (!$taskActivityStatus->isAllowedStatusChange($desiredStatus, $currStatus))
	{
		// can't update due to task activity status logic
		return;
	}

	$settings['ACTIVITY_STATUS'] = $desiredStatus;
	$this->update(
		$activity->getId(),
		[
			'SETTINGS' => $settings,
		]
	);
}

Добавить комментарий