• Модуль: bizproc
  • Путь к файлу: ~/bitrix/modules/bizproc/lib/automation/engine/template.php
  • Класс: BitrixBizprocAutomationEngineTemplate
  • Вызов: Template::addBizprocTemplate
protected function addBizprocTemplate($userId)
{
	$userId = (int)$userId;
	$documentType = $this->getDocumentType();

	$raw = $this->template;
	$raw['DOCUMENT_TYPE'] = $documentType;
	$raw['NAME'] = $raw['NAME'] ?? $this->makeTemplateName();
	$raw['USER_ID'] = $userId;
	$raw['MODIFIER_USER'] = new CBPWorkflowTemplateUser($userId);

	$result = new Result();
	try
	{
		$raw['ID'] = CBPWorkflowTemplateLoader::add($raw, $userId === 1);
		$result->setData(array('ID' => $raw['ID']));

		$raw['MODULE_ID'] = $documentType[0];
		$raw['ENTITY'] = $documentType[1];
		$raw['DOCUMENT_TYPE'] = $documentType[2];
		$raw['PARAMETERS'] = [];
		$raw['CONSTANTS'] = [];
		$this->template = $raw;
	}
	catch (Exception $e)
	{
		$result->addError(new Error($e->getMessage()));
	}

	return $result;
}