• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/automation/engine/runtime.php
  • Класс: BitrixBizprocAutomationEngineRuntime
  • Вызов: Runtime::getCurrentWorkflowId
public function getCurrentWorkflowId(): ?string
{
	$documentType = $this->getTarget()->getDocumentType();

	$template = new Template(
		$documentType,
		$this->getTarget()->getDocumentStatus()
	);

	if ($template->getId() > 0)
	{
		$filter = [
			'=DOCUMENT_ID' => $this->getTarget()->getDocumentId(),
			'=TEMPLATE.ID' => $template->getId(),
		];

		if ($this->isDebug())
		{
			$session = BizprocDebuggerSessionManager::getActiveSession();
			$filter['@ID'] = $session->getWorkflowContexts()->getWorkflowIdList();
		}

		$row = WorkflowStateTable::getList([
			'select' => ['ID'],
			'filter' => $filter,
			'order' => ['STARTED' => 'DESC'],
			'limit' => 1,
		])->fetch();

		return $row ? $row['ID'] : null;
	}

	return null;
}