Item::launchOperation

  1. Bitrix24 API (v. 23.675.0)
  2. crm
  3. Item
  4. launchOperation
  • Модуль: crm
  • Путь к файлу: ~/bitrix/modules/crm/lib/integration/bizproc/document/item.php
  • Класс: Bitrix\Crm\Integration\BizProc\Document\Item
  • Вызов: Item::launchOperation
static function launchOperation(Operation $operation): Result
{
	$dbConnection = Application::getConnection();
	if (static::shouldUseTransaction())
	{
		$dbConnection->startTransaction();
	}

	$isBizProcEnabled = $operation->isBizProcEnabled();

	// BizProc is disabled because it will be launched differently further
	$operation->disableBizProc()->disableCheckFields()->disableCheckAccess();
	$operationResult = $operation->launch();

	if (
		$operationResult->isSuccess()
		&& $isBizProcEnabled
		&& \COption::GetOptionString('crm', 'start_bp_within_bp', 'N') === 'Y'
	)
	{
		$item = $operation->getItem();
		$itemType = \CCrmOwnerType::ResolveName($item->getEntityTypeId());
		$itemId = $item->isNew() ? false : $item->getId();
		$documentId = $item->isNew() ? false : $itemType . '_' . $item->getId();

		$bizProc = new \CCrmBizProc($itemType);
		if (!$bizProc->CheckFields($documentId, true) || !$bizProc->StartWorkflow($itemId))
		{
			$operationResult->addError(new Error($bizProc->LAST_ERROR));
		}
	}

	if (static::shouldUseTransaction())
	{
		$operationResult->isSuccess() ? $dbConnection->commitTransaction() : $dbConnection->rollbackTransaction();
	}

	return $operationResult;
}

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