Task::onAfterUpdate

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Task
  4. onAfterUpdate
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/activity/provider/tasks/task.php
  • Класс: Bitrix\Crm\Activity\Provider\Tasks\Task
  • Вызов: Task::onAfterUpdate
static function onAfterUpdate(
	int $id,
	array $changedFields,
	array $oldFields,
	array $newFields,
	array $params = null
)
{
	$taskId = $newFields['ASSOCIATED_ENTITY_ID'] ?? 0;
	if ($taskId <= 0)
	{
		return;
	}

	$task = TaskObject::getObject($taskId);
	if (is_null($task))
	{
		return;
	}

	$bindings = $newFields['BINDINGS'] ?? [];
	if (empty($bindings))
	{
		return;
	}
	$taskCrmFields = $task->getCrmFields();
	$crmFields = array_unique(array_merge($taskCrmFields, self::prepareBindingsToTask($bindings)));
	if (
		empty(array_diff($crmFields, $taskCrmFields))
		&& empty(array_diff($taskCrmFields, $crmFields))
	)
	{
		return;
	}

	TaskHandler::getHandler()->update($taskId,[
		self::TASK_CRM_FIELD => $crmFields
	]);
}

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