• Модуль: rpa
  • Путь к файлу: ~/bitrix/modules/rpa/lib/controller/item.php
  • Класс: BitrixRpaControllerItem
  • Вызов: Item::updateAction
public function updateAction(BitrixRpaModelType $type, int $id, array $fields, string $eventId = null): ?array
{
	$item = $type->getItem($id);
	if(!$item)
	{
		$this->addError(new Error(Loc::getMessage('RPA_ITEM_NOT_FOUND_ERROR')));
		return null;
	}
	$previousItemId = null;
	if(isset($fields['previousItemId']))
	{
		$previousItemId = (int) $fields['previousItemId'];
	}

	$stageId = $item->getStageId();
	if(isset($fields['stageId']))
	{
		$item->setStageId($fields['stageId']);
	}
	$this->processFields($item, $fields);
	$command = Driver::getInstance()->getFactory()->getUpdateCommand($item);
	if($eventId)
	{
		$command->setPullEventId($eventId);
	}
	$result = $command->run();
	if($result->isSuccess())
	{
		$item = $command->getItem();
		if($previousItemId !== null && $item->getStageId() === $stageId)
		{
			$userId = Driver::getInstance()->getUserId();
			if($userId > 0)
			{
				$sort = $this->getSortByPreviousItemId($item, $userId, $previousItemId);
				ItemSortTable::setSortForItem($item, $userId, $sort);
			}
		}
		return [
			'item' => $this->prepareItemData($item, [
				'withDisplay' => ($this->getScope() !== self::SCOPE_REST),
				'withTasks' => true,
				'withUsers' => true,
				'withPermissions' => ($this->getScope() !== self::SCOPE_REST),
			]),
		];
	}

	$this->deleteUploadedFiles();
	$this->addErrors($result->getErrors());

	return null;
}